java - How can i format a decimal value into hours and minutes? -
for example if user input 1.71 (1 hour , 71 minutes), want convert 2.11 (2 hours , 11 minutes)
decimalformat time = new decimalformat("##.## p.m"); int userinput = 1.71; system.out.print(time.format(userinput));
parse input date , format date output format:
scanner sc = new scanner(system.in); dateformat df = new simpledateformat("hh.mm"); dateformat dfout = new simpledateformat("h.mm a"); date date = df.parse(sc.next()); system.out.println(dfout.format(date));
Comments
Post a Comment