Java Millisecond to Hour milliseconds(long p_days, long p_hours, long p_minutes, long p_hoursPerBusinessDay)

Here you can find the source of milliseconds(long p_days, long p_hours, long p_minutes, long p_hoursPerBusinessDay)

Description

Convert the given number of days, hours, and minutes into the corresponding number of milliseconds.

License

Apache License

Parameter

Parameter Description
p_days a long value representing the number of days
p_hours a long value representing the number of hours
p_minutes a long value representing the number of minutes
p_hoursPerBusinessDay - The conversion factor that indicates the number of business hours within a day. This value is an attribute of a calendar.

Return

a long value representing the number of milliseconds

Declaration

public static long milliseconds(long p_days, long p_hours, long p_minutes, long p_hoursPerBusinessDay) 

Method Source Code

//package com.java2s;
/**//from  w  ww .  ja v a2  s  .c o  m
 *  Copyright 2009 Welocalize, Inc. 
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  
 *  You may obtain a copy of the License at 
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  
 */

public class Main {
    private static final long MILLIS_PER_SECOND = 1000;
    private static final long SECONDS_PER_MINUTE = 60;
    private static final long MINUTES_PER_HOUR = 60;
    private static final long HOURS_PER_DAY = 24;

    public static long milliseconds(String p_days, String p_hours, String p_minutes) {
        return milliseconds(Long.valueOf(p_days), Long.valueOf(p_hours), Long.valueOf(p_minutes), HOURS_PER_DAY);
    }

    /**
     * Convert the given number of days, hours, and minutes into the
     * corresponding number of milliseconds.  Return the result.
     *
     * @param p_days a long value representing the number of days
     * @param p_hours a long value representing the number of hours
     * @param p_minutes a long value representing the number of minutes
     *
     * @return a long value representing the number of milliseconds
     */
    public static long milliseconds(long p_days, long p_hours, long p_minutes) {
        return milliseconds(p_days, p_hours, p_minutes, HOURS_PER_DAY);
    }

    /**
     * Convert the given number of days, hours, and minutes into the
     * corresponding number of milliseconds.  Return the result.
     *
     * @param p_days a long value representing the number of days
     * @param p_hours a long value representing the number of hours
     * @param p_minutes a long value representing the number of minutes
     * @param p_hoursPerBusinessDay - The conversion factor that indicates
     * the number of business hours within a day.  This value is an 
     * attribute of a calendar.
     *
     * @return a long value representing the number of milliseconds
     */
    public static long milliseconds(long p_days, long p_hours, long p_minutes, long p_hoursPerBusinessDay) {
        long seconds = p_days * p_hoursPerBusinessDay * MINUTES_PER_HOUR * SECONDS_PER_MINUTE;
        seconds += p_hours * MINUTES_PER_HOUR * SECONDS_PER_MINUTE;
        seconds += p_minutes * SECONDS_PER_MINUTE;
        return seconds * MILLIS_PER_SECOND;
    }
}

Related

  1. getHoursIntoMilliseconds(int nbHours)
  2. getHourSpareFromMilliSecond(int milliSecond)
  3. getMilliSecondByHourAndMins(int hour, int min)
  4. getMillisFromHours(String hours)
  5. getMillisFromHours(String hours)
  6. millisecondsToHours(long ms)
  7. millisecondToHour(Long millisecond)
  8. millisToHours(double millis)
  9. millisToHours(long millis)