Here you can find the source of hoursMinutes(long p_milliseconds)
Parameter | Description |
---|---|
p_milliseconds | a long value representing the number of milliseconds to convert |
public static long[] hoursMinutes(long p_milliseconds)
//package com.java2s; /**/*from ww w. ja va 2s . c om*/ * 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; /** * Convert the given number of milliseconds into an array of longs, * where each long represents the hours, and minutes respectively. * * @param p_milliseconds a long value representing the number of milliseconds * to convert * * @return an array of longs, where long[0] = hours, and * long[1] = minutes. */ public static long[] hoursMinutes(long p_milliseconds) { long[] hm = new long[2]; long seconds = p_milliseconds / MILLIS_PER_SECOND; long minutes = seconds / SECONDS_PER_MINUTE; long hours = minutes / MINUTES_PER_HOUR; minutes -= (hours * MINUTES_PER_HOUR); hm[0] = hours; hm[1] = minutes; return hm; } }