Java Day From daysAndHours(int hours)

Here you can find the source of daysAndHours(int hours)

Description

Converts hours to days and hours.

License

Open Source License

Declaration

public static Float daysAndHours(int hours) 

Method Source Code

//package com.java2s;
/**/*from  ww  w . j  ava 2s  .  co  m*/
 * Exhibit A - UIRF Open-source Based Public Software License.
 * 
 * The contents of this file are subject to the UIRF Open-source Based Public
 * Software License(the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * openelis.uhl.uiowa.edu
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * 
 * The Original Code is OpenELIS code.
 * 
 * The Initial Developer of the Original Code is The University of Iowa.
 * Portions created by The University of Iowa are Copyright 2006-2008. All
 * Rights Reserved.
 * 
 * Contributor(s): ______________________________________.
 * 
 * Alternatively, the contents of this file marked "Separately-Licensed" may be
 * used under the terms of a UIRF Software license ("UIRF Software License"), in
 * which case the provisions of a UIRF Software License are applicable instead
 * of those above.
 */

public class Main {
    /**
     * Converts hours to days and hours. 4.09 is 4 days and 9 hours
     */
    public static Float daysAndHours(int hours) {
        int days, hrs;
        String s = null;
        days = Math.abs(hours) / 24;
        hrs = Math.abs(hours) % 24;
        if (hrs < 10)
            s = days + ".0" + hrs;
        else
            s = days + "." + hrs;
        if (hours < 0)
            s = "-" + s;
        float f = Float.parseFloat(s);
        return f;
    }
}

Related

  1. days(int d)
  2. days(int month, int year)
  3. days(int num)
  4. days(int year, int month)
  5. daysAfter(Date earlierDate, Date laterDate)
  6. daysBetweenTime(long start, long end)
  7. daysInFebruary(int year)
  8. daysInMonthForYear(int commonMonthIndex, int yearInteger)
  9. daysOfTwo(Date date1, Date date2)