Here you can find the source of time2string(double t)
Parameter | Description |
---|---|
t | time value in hours. |
public static String time2string(double t)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; public class Main { /**//from w w w. j av a2 s. c o m * Converts double value of a time stamp to a string suitable for display. * @param t time value in hours. * @return time string. */ public static String time2string(double t) { NumberFormat form = NumberFormat.getInstance(); form.setMinimumIntegerDigits(2); form.setMinimumFractionDigits(0); form.setMaximumIntegerDigits(2); form.setMaximumFractionDigits(2); double stime = t; int hours = (int) Math.floor(stime); stime = (stime - hours) * 60; int min = (int) Math.floor(stime); stime = (stime - min) * 60; //int sec = (int)Math.floor(stime); return form.format(hours) + "h" + form.format(min) + "m" + form.format(stime) + "s"; } }