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 @@
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Janek Bogucki * @author Janek Bogucki
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz
* @since 2.0 * @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 { public class DateUtils {
@ -80,19 +81,19 @@ public class DateUtils {
/** /**
* Number of milliseconds in a standard second. * 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. * 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. * 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. * 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 * This is half a month, so this represents whether a date is in the top
@ -700,5 +701,34 @@ public void remove() {
throw new UnsupportedOperationException(); 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 @@
* @author Stephen Colebourne * @author Stephen Colebourne
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @since 2.0 * @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 { class DurationFormatUtils {
// TODO: Make class public once methods can fully select which fields to output // 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) { public static String formatISO(long millis) {
int hours, minutes, seconds, milliseconds; int hours, minutes, seconds, milliseconds;
hours = (int) (millis / DateUtils.MILLIS_IN_HOUR); hours = (int) (millis / DateUtils.MILLIS_PER_HOUR);
millis = millis - (hours * DateUtils.MILLIS_IN_HOUR); millis = millis - (hours * DateUtils.MILLIS_PER_HOUR);
minutes = (int) (millis / DateUtils.MILLIS_IN_MINUTE); minutes = (int) (millis / DateUtils.MILLIS_PER_MINUTE);
millis = millis - (minutes * DateUtils.MILLIS_IN_MINUTE); millis = millis - (minutes * DateUtils.MILLIS_PER_MINUTE);
seconds = (int) (millis / DateUtils.MILLIS_IN_SECOND); seconds = (int) (millis / DateUtils.MILLIS_PER_SECOND);
millis = millis - (seconds * DateUtils.MILLIS_IN_SECOND); millis = millis - (seconds * DateUtils.MILLIS_PER_SECOND);
milliseconds = (int) millis; milliseconds = (int) millis;
StringBuffer buf = new StringBuffer(32); StringBuffer buf = new StringBuffer(32);
@ -145,10 +145,10 @@ public static String formatWords(
boolean suppressLeadingZeroElements, boolean suppressLeadingZeroElements,
boolean suppressTrailingZeroElements) { boolean suppressTrailingZeroElements) {
long[] values = new long[4]; long[] values = new long[4];
values[0] = millis / DateUtils.MILLIS_IN_DAY; values[0] = millis / DateUtils.MILLIS_PER_DAY;
values[1] = (millis / DateUtils.MILLIS_IN_HOUR) % 24; values[1] = (millis / DateUtils.MILLIS_PER_HOUR) % 24;
values[2] = (millis / DateUtils.MILLIS_IN_MINUTE) % 60; values[2] = (millis / DateUtils.MILLIS_PER_MINUTE) % 60;
values[3] = (millis / DateUtils.MILLIS_IN_SECOND) % 60; values[3] = (millis / DateUtils.MILLIS_PER_SECOND) % 60;
String[] fieldsOne = { " day ", " hour ", " minute ", " second" }; String[] fieldsOne = { " day ", " hour ", " minute ", " second" };
String[] fieldsPlural = { " days ", " hours ", " minutes ", " seconds" }; String[] fieldsPlural = { " days ", " hours ", " minutes ", " seconds" };