Deprecated integer MILLIS_IN_* constants and replaced with long versions

named MILLIS_PER_*.
PR # 25627
Reported by Nikolay Metchev


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2003-12-23 03:54:14 +00:00
parent d206d8cfdc
commit e2225defe6
2 changed files with 47 additions and 17 deletions

View File

@ -68,8 +68,9 @@ import java.util.TimeZone;
* @author Stephen Colebourne
* @author Janek Bogucki
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz
* @since 2.0
* @version $Id: DateUtils.java,v 1.16 2003/08/18 21:52:39 ggregory Exp $
* @version $Id: DateUtils.java,v 1.17 2003/12/23 03:54:14 psteitz Exp $
*/
public class DateUtils {
@ -80,19 +81,19 @@ public class DateUtils {
/**
* Number of milliseconds in a standard second.
*/
public static final int MILLIS_IN_SECOND = 1000;
public static final long MILLIS_PER_SECOND = 1000;
/**
* Number of milliseconds in a standard minute.
*/
public static final int MILLIS_IN_MINUTE = 60 * 1000;
public static final long MILLIS_PER_MINUTE = 60 * 1000;
/**
* Number of milliseconds in a standard hour.
*/
public static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
public static final long MILLIS_PER_HOUR = 60 * 60 * 1000;
/**
* Number of milliseconds in a standard day.
*/
public static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
public static final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
/**
* This is half a month, so this represents whether a date is in the top
@ -700,5 +701,34 @@ public class DateUtils {
throw new UnsupportedOperationException();
}
}
//-------------------------------------------------------------------------
// Deprecated int constants
// TODO: Remove in 3.0
/**
* Number of milliseconds in a standard second.
*
* @deprecated Use MILLIS_PER_SECOND. This will be removed in Commons Lang 3.0.
*/
public static final int MILLIS_IN_SECOND = 1000;
/**
* Number of milliseconds in a standard minute.
*
* @deprecated Use MILLIS_PER_MINUTE. This will be removed in Commons Lang 3.0.
*/
public static final int MILLIS_IN_MINUTE = 60 * 1000;
/**
* Number of milliseconds in a standard hour.
*
* @deprecated Use MILLIS_PER_HOUR. This will be removed in Commons Lang 3.0.
*/
public static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
/**
* Number of milliseconds in a standard day.
*
* @deprecated Use MILLIS_PER_DAY. This will be removed in Commons Lang 3.0.
*/
public static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
}

View File

@ -62,7 +62,7 @@ package org.apache.commons.lang.time;
* @author Stephen Colebourne
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @since 2.0
* @version $Id: DurationFormatUtils.java,v 1.7 2003/12/20 22:19:21 psteitz Exp $
* @version $Id: DurationFormatUtils.java,v 1.8 2003/12/23 03:54:14 psteitz Exp $
*/
class DurationFormatUtils {
// TODO: Make class public once methods can fully select which fields to output
@ -106,12 +106,12 @@ class DurationFormatUtils {
*/
public static String formatISO(long millis) {
int hours, minutes, seconds, milliseconds;
hours = (int) (millis / DateUtils.MILLIS_IN_HOUR);
millis = millis - (hours * DateUtils.MILLIS_IN_HOUR);
minutes = (int) (millis / DateUtils.MILLIS_IN_MINUTE);
millis = millis - (minutes * DateUtils.MILLIS_IN_MINUTE);
seconds = (int) (millis / DateUtils.MILLIS_IN_SECOND);
millis = millis - (seconds * DateUtils.MILLIS_IN_SECOND);
hours = (int) (millis / DateUtils.MILLIS_PER_HOUR);
millis = millis - (hours * DateUtils.MILLIS_PER_HOUR);
minutes = (int) (millis / DateUtils.MILLIS_PER_MINUTE);
millis = millis - (minutes * DateUtils.MILLIS_PER_MINUTE);
seconds = (int) (millis / DateUtils.MILLIS_PER_SECOND);
millis = millis - (seconds * DateUtils.MILLIS_PER_SECOND);
milliseconds = (int) millis;
StringBuffer buf = new StringBuffer(32);
@ -145,10 +145,10 @@ class DurationFormatUtils {
boolean suppressLeadingZeroElements,
boolean suppressTrailingZeroElements) {
long[] values = new long[4];
values[0] = millis / DateUtils.MILLIS_IN_DAY;
values[1] = (millis / DateUtils.MILLIS_IN_HOUR) % 24;
values[2] = (millis / DateUtils.MILLIS_IN_MINUTE) % 60;
values[3] = (millis / DateUtils.MILLIS_IN_SECOND) % 60;
values[0] = millis / DateUtils.MILLIS_PER_DAY;
values[1] = (millis / DateUtils.MILLIS_PER_HOUR) % 24;
values[2] = (millis / DateUtils.MILLIS_PER_MINUTE) % 60;
values[3] = (millis / DateUtils.MILLIS_PER_SECOND) % 60;
String[] fieldsOne = { " day ", " hour ", " minute ", " second" };
String[] fieldsPlural = { " days ", " hours ", " minutes ", " seconds" };