Here you can find the source of formatHours(Locale locale, double totalhours)
Parameter | Description |
---|---|
locale | locale to format for |
totalhours | number of hours to display |
public static String formatHours(Locale locale, double totalhours)
//package com.java2s; /*/*from www .j av a 2 s . c o m*/ This file is part of Timelord. Copyright 2005-2009 Jordan Reed Timelord is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Timelord is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Timelord. If not, see <http://www.gnu.org/licenses/>. */ import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; public class Main { /** Number format for the time. */ public static final NumberFormat HOURS_FORMAT = new DecimalFormat("00.00"); /** * Formats the hours display for the given locale. * * @param locale locale to format for * @param totalhours number of hours to display * @return the format as a string */ public static String formatHours(Locale locale, double totalhours) { /* int hours = (int) Math.floor(totalhours); int minutes = (int) ((totalhours-hours) * 60); String result = hours + "h " + minutes + "m"; */ String result = HOURS_FORMAT.format(totalhours); return result; } }