git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1077942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2011-03-04 13:41:41 +00:00
parent 3f4676370a
commit f68bbdbbb5
2 changed files with 47 additions and 46 deletions

View File

@ -24,7 +24,7 @@ import java.util.TimeZone;
/**
* <p>Date and time formatting utilities and constants.</p>
*
* <p>Formatting is performed using the
* <p>Formatting is performed using the thread-safe
* {@link org.apache.commons.lang3.time.FastDateFormat} class.</p>
*
* @author Apache Software Foundation
@ -121,7 +121,7 @@ public class DateFormatUtils {
* <p>Formats a date/time into a specific pattern using the UTC time zone.</p>
*
* @param millis the date to format expressed in milliseconds
* @param pattern the pattern to use to format the date
* @param pattern the pattern to use to format the date, not null
* @return the formatted date
*/
public static String formatUTC(long millis, String pattern) {
@ -131,8 +131,8 @@ public class DateFormatUtils {
/**
* <p>Formats a date/time into a specific pattern using the UTC time zone.</p>
*
* @param date the date to format
* @param pattern the pattern to use to format the date
* @param date the date to format, not null
* @param pattern the pattern to use to format the date, not null
* @return the formatted date
*/
public static String formatUTC(Date date, String pattern) {
@ -143,7 +143,7 @@ public class DateFormatUtils {
* <p>Formats a date/time into a specific pattern using the UTC time zone.</p>
*
* @param millis the date to format expressed in milliseconds
* @param pattern the pattern to use to format the date
* @param pattern the pattern to use to format the date, not null
* @param locale the locale to use, may be <code>null</code>
* @return the formatted date
*/
@ -154,8 +154,8 @@ public class DateFormatUtils {
/**
* <p>Formats a date/time into a specific pattern using the UTC time zone.</p>
*
* @param date the date to format
* @param pattern the pattern to use to format the date
* @param date the date to format, not null
* @param pattern the pattern to use to format the date, not null
* @param locale the locale to use, may be <code>null</code>
* @return the formatted date
*/
@ -167,7 +167,7 @@ public class DateFormatUtils {
* <p>Formats a date/time into a specific pattern.</p>
*
* @param millis the date to format expressed in milliseconds
* @param pattern the pattern to use to format the date
* @param pattern the pattern to use to format the date, not null
* @return the formatted date
*/
public static String format(long millis, String pattern) {
@ -177,8 +177,8 @@ public class DateFormatUtils {
/**
* <p>Formats a date/time into a specific pattern.</p>
*
* @param date the date to format
* @param pattern the pattern to use to format the date
* @param date the date to format, not null
* @param pattern the pattern to use to format the date, not null
* @return the formatted date
*/
public static String format(Date date, String pattern) {
@ -188,8 +188,8 @@ public class DateFormatUtils {
/**
* <p>Formats a calendar into a specific pattern.</p>
*
* @param calendar the calendar to format
* @param pattern the pattern to use to format the calendar
* @param calendar the calendar to format, not null
* @param pattern the pattern to use to format the calendar, not null
* @return the formatted calendar
* @see FastDateFormat#format(Calendar)
* @since 2.4
@ -202,7 +202,7 @@ public class DateFormatUtils {
* <p>Formats a date/time into a specific pattern in a time zone.</p>
*
* @param millis the time expressed in milliseconds
* @param pattern the pattern to use to format the date
* @param pattern the pattern to use to format the date, not null
* @param timeZone the time zone to use, may be <code>null</code>
* @return the formatted date
*/
@ -213,8 +213,8 @@ public class DateFormatUtils {
/**
* <p>Formats a date/time into a specific pattern in a time zone.</p>
*
* @param date the date to format
* @param pattern the pattern to use to format the date
* @param date the date to format, not null
* @param pattern the pattern to use to format the date, not null
* @param timeZone the time zone to use, may be <code>null</code>
* @return the formatted date
*/
@ -225,8 +225,8 @@ public class DateFormatUtils {
/**
* <p>Formats a calendar into a specific pattern in a time zone.</p>
*
* @param calendar the calendar to format
* @param pattern the pattern to use to format the calendar
* @param calendar the calendar to format, not null
* @param pattern the pattern to use to format the calendar, not null
* @param timeZone the time zone to use, may be <code>null</code>
* @return the formatted calendar
* @see FastDateFormat#format(Calendar)
@ -240,7 +240,7 @@ public class DateFormatUtils {
* <p>Formats a date/time into a specific pattern in a locale.</p>
*
* @param millis the date to format expressed in milliseconds
* @param pattern the pattern to use to format the date
* @param pattern the pattern to use to format the date, not null
* @param locale the locale to use, may be <code>null</code>
* @return the formatted date
*/
@ -251,8 +251,8 @@ public class DateFormatUtils {
/**
* <p>Formats a date/time into a specific pattern in a locale.</p>
*
* @param date the date to format
* @param pattern the pattern to use to format the date
* @param date the date to format, not null
* @param pattern the pattern to use to format the date, not null
* @param locale the locale to use, may be <code>null</code>
* @return the formatted date
*/
@ -263,8 +263,8 @@ public class DateFormatUtils {
/**
* <p>Formats a calendar into a specific pattern in a locale.</p>
*
* @param calendar the calendar to format
* @param pattern the pattern to use to format the calendar
* @param calendar the calendar to format, not null
* @param pattern the pattern to use to format the calendar, not null
* @param locale the locale to use, may be <code>null</code>
* @return the formatted calendar
* @see FastDateFormat#format(Calendar)
@ -278,7 +278,7 @@ public class DateFormatUtils {
* <p>Formats a date/time into a specific pattern in a time zone and locale.</p>
*
* @param millis the date to format expressed in milliseconds
* @param pattern the pattern to use to format the date
* @param pattern the pattern to use to format the date, not null
* @param timeZone the time zone to use, may be <code>null</code>
* @param locale the locale to use, may be <code>null</code>
* @return the formatted date
@ -290,8 +290,8 @@ public class DateFormatUtils {
/**
* <p>Formats a date/time into a specific pattern in a time zone and locale.</p>
*
* @param date the date to format
* @param pattern the pattern to use to format the date
* @param date the date to format, not null
* @param pattern the pattern to use to format the date, not null, not null
* @param timeZone the time zone to use, may be <code>null</code>
* @param locale the locale to use, may be <code>null</code>
* @return the formatted date
@ -304,8 +304,8 @@ public class DateFormatUtils {
/**
* <p>Formats a calendar into a specific pattern in a time zone and locale.</p>
*
* @param calendar the calendar to format
* @param pattern the pattern to use to format the calendar
* @param calendar the calendar to format, not null
* @param pattern the pattern to use to format the calendar, not null
* @param timeZone the time zone to use, may be <code>null</code>
* @param locale the locale to use, may be <code>null</code>
* @return the formatted calendar

View File

@ -75,7 +75,7 @@ public class DurationFormatUtils {
* <i>H</i>:<i>m</i>:<i>s</i>.<i>S</i>.</p>
*
* @param durationMillis the duration to format
* @return the time as a String
* @return the formatted duration, not null
*/
public static String formatDurationHMS(long durationMillis) {
return formatDuration(durationMillis, "H:mm:ss.SSS");
@ -90,7 +90,7 @@ public class DurationFormatUtils {
* ISO format pattern, such as P7D6TH5M4.321S.</p>
*
* @param durationMillis the duration to format
* @return the time as a String
* @return the formatted duration, not null
*/
public static String formatDurationISO(long durationMillis) {
return formatDuration(durationMillis, ISO_EXTENDED_FORMAT_PATTERN, false);
@ -104,8 +104,8 @@ public class DurationFormatUtils {
* format pattern. Months and larger are not used.</p>
*
* @param durationMillis the duration to format
* @param format the way in which to format the duration
* @return the time as a String
* @param format the way in which to format the duration, not null
* @return the formatted duration, not null
*/
public static String formatDuration(long durationMillis, String format) {
return formatDuration(durationMillis, format, true);
@ -120,9 +120,9 @@ public class DurationFormatUtils {
* format pattern. Months and larger are not used.</p>
*
* @param durationMillis the duration to format
* @param format the way in which to format the duration
* @param format the way in which to format the duration, not null
* @param padWithZeros whether to pad the left hand side of numbers with 0's
* @return the time as a String
* @return the formatted duration, not null
*/
public static String formatDuration(long durationMillis, String format, boolean padWithZeros) {
@ -166,7 +166,7 @@ public class DurationFormatUtils {
* @param durationMillis the elapsed time to report in milliseconds
* @param suppressLeadingZeroElements suppresses leading 0 elements
* @param suppressTrailingZeroElements suppresses trailing 0 elements
* @return the formatted text in days/hours/minutes/seconds
* @return the formatted text in days/hours/minutes/seconds, not null
*/
public static String formatDurationWords(
long durationMillis,
@ -229,7 +229,7 @@ public class DurationFormatUtils {
*
* @param startMillis the start of the duration to format
* @param endMillis the end of the duration to format
* @return the time as a String
* @return the formatted duration, not null
*/
public static String formatPeriodISO(long startMillis, long endMillis) {
return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault());
@ -241,8 +241,8 @@ public class DurationFormatUtils {
*
* @param startMillis the start of the duration
* @param endMillis the end of the duration
* @param format the way in which to format the duration
* @return the time as a String
* @param format the way in which to format the duration, not null
* @return the formatted duration, not null
*/
public static String formatPeriod(long startMillis, long endMillis, String format) {
return formatPeriod(startMillis, endMillis, format, true, TimeZone.getDefault());
@ -266,10 +266,10 @@ public class DurationFormatUtils {
*
* @param startMillis the start of the duration
* @param endMillis the end of the duration
* @param format the way in which to format the duration
* @param padWithZeros whether to pad the left hand side of numbers with 0's
* @param timezone the millis are defined in
* @return the time as a String
* @param format the way in which to format the duration, not null
* @param padWithZeros whether to pad the left hand side of numbers with 0's
* @param timezone the millis are defined in
* @return the formatted duration, not null
*/
public static String formatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros,
TimeZone timezone) {
@ -482,7 +482,7 @@ public class DurationFormatUtils {
/**
* Parses a classic date format string into Tokens
*
* @param format to parse
* @param format the format to parse, not null
* @return array of Token[]
*/
static Token[] lexx(String format) {
@ -541,6 +541,7 @@ public class DurationFormatUtils {
return list.toArray( new Token[list.size()] );
}
//-----------------------------------------------------------------------
/**
* Element that is parsed from the format pattern.
*/
@ -641,11 +642,11 @@ public class DurationFormatUtils {
}
/**
* Returns a hashcode for the token equal to the
* hashcode for the token's value. Thus 'TT' and 'TTTT'
* will have the same hashcode.
* Returns a hash code for the token equal to the
* hash code for the token's value. Thus 'TT' and 'TTTT'
* will have the same hash code.
*
* @return The hashcode for the token
* @return The hash code for the token
*/
@Override
public int hashCode() {