Java Hour Format formatHours(Locale locale, double totalhours)

Here you can find the source of formatHours(Locale locale, double totalhours)

Description

Formats the hours display for the given locale.

License

Open Source License

Parameter

Parameter Description
locale locale to format for
totalhours number of hours to display

Return

the format as a string

Declaration

public static String formatHours(Locale locale, double totalhours) 

Method Source Code

//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;
    }
}

Related

  1. formatFullDate(Object date)
  2. formatFullTime(Date date)
  3. formatHDate(java.util.Date date)
  4. formatHoraFormatadaHHMMSSStr(Date hora)
  5. formatHour(final Date date)
  6. formatHours(long millis)
  7. formatHourTimeHToString(Date srcDate)
  8. formatHttpDate(Date d)
  9. formatHttpDate(Date date)