de.bea.domingo.util
Class DateUtil

java.lang.Object
  extended by de.bea.domingo.util.DateUtil

public final class DateUtil
extends java.lang.Object

Static utility methods for date operations and conversions.

Author:
Kurt Riede

Field Summary
static java.lang.String DATE_FORMAT
          Date format used for parsing.
static java.lang.String DATE_TIME_FORMAT
          Date/time format used for parsing.
static java.lang.String TIME_FORMAT
          Time format used for parsing.
 
Method Summary
static java.lang.String getDateString(java.util.Calendar calendar)
          Formats the date of a Calendar instance to a String.
static java.lang.String getDateString(java.util.Calendar calendar, java.util.Locale locale)
          Formats the date of a Calendar instance to a String.
static java.lang.String getDateTimeString(java.util.Calendar calendar)
          Formats the date and time time of a Calendar instance to a String.
static java.lang.String getDateTimeString(java.util.Calendar date, java.util.Calendar time)
          Formats the date and time time of a Calendar instance to a String.
static java.lang.String getDateTimeString(java.util.Calendar date, java.util.Calendar time, java.util.Locale locale)
          Formats the date and time time of a Calendar instance to a String.
static java.lang.String getDateTimeString(java.util.Calendar calendar, java.util.Locale locale)
          Formats the date and time time of a Calendar instance to a String.
static java.lang.String getTimeString(java.util.Calendar calendar)
          Formats the time of a Calendar instance to a String.
static java.lang.String getTimeString(java.util.Calendar calendar, java.util.Locale locale)
          Formats the time of a Calendar instance to a String.
static java.util.Calendar parseDate(java.lang.String date, boolean adjustToLocalTimeZone)
          Parses a date given as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
Date format used for parsing. The format it compatible with the format of class java.text.SimpleDateFormat.

See Also:
Constant Field Values

TIME_FORMAT

public static final java.lang.String TIME_FORMAT
Time format used for parsing. The format it compatible with the format of class java.text.SimpleDateFormat.

See Also:
Constant Field Values

DATE_TIME_FORMAT

public static final java.lang.String DATE_TIME_FORMAT
Date/time format used for parsing. The format it compatible with the format of class java.text.SimpleDateFormat.

See Also:
Constant Field Values
Method Detail

parseDate

public static java.util.Calendar parseDate(java.lang.String date,
                                           boolean adjustToLocalTimeZone)
                                    throws java.lang.IndexOutOfBoundsException,
                                           java.lang.NumberFormatException
Parses a date given as a string. The format of the resulting string is DATE_TIME_FORMAT.

Parameters:
date - a date formatted as a string
adjustToLocalTimeZone - if result should be adjusted to local time zone or not
Returns:
the date as a java.util.Calendar or null if argument string is null or empty
Throws:
java.lang.IndexOutOfBoundsException - if the String is too short
java.lang.NumberFormatException - if a date/time component is out of range or cannot be parsed

getDateTimeString

public static java.lang.String getDateTimeString(java.util.Calendar date,
                                                 java.util.Calendar time)
Formats the date and time time of a Calendar instance to a String. The format of the resulting string is the short date/time format of the default locale.

Parameters:
date - the date as a java.util.Calendar
time - the time as a java.util.Calendar
Returns:
date as a formatted string

getDateTimeString

public static java.lang.String getDateTimeString(java.util.Calendar date,
                                                 java.util.Calendar time,
                                                 java.util.Locale locale)
Formats the date and time time of a Calendar instance to a String. The format of the resulting string is the short date/time format of the given locale.

Parameters:
date - the date as a java.util.Calendar
time - the time as a java.util.Calendar
locale - locale
Returns:
date as a formatted string

getDateTimeString

public static java.lang.String getDateTimeString(java.util.Calendar calendar)
Formats the date and time time of a Calendar instance to a String. The format of the resulting string is the short date/time format of the default locale.

Parameters:
calendar - the date as a java.util.Calendar
Returns:
date as a formatted string

getDateTimeString

public static java.lang.String getDateTimeString(java.util.Calendar calendar,
                                                 java.util.Locale locale)
Formats the date and time time of a Calendar instance to a String. The format of the resulting string is the short date/time format of the given locale.

Parameters:
calendar - the date as a java.util.Calendar
locale - locale
Returns:
date as a formatted string

getDateString

public static java.lang.String getDateString(java.util.Calendar calendar)
Formats the date of a Calendar instance to a String. The format of the resulting string is the short date/time format of the defaultlocale.

Parameters:
calendar - the date as a java.util.Calendar
Returns:
date as a formatted string

getDateString

public static java.lang.String getDateString(java.util.Calendar calendar,
                                             java.util.Locale locale)
Formats the date of a Calendar instance to a String. The format of the resulting string is the short date/time format of the given locale.

Parameters:
calendar - the date as a java.util.Calendar
locale - locale
Returns:
date as a formatted string

getTimeString

public static java.lang.String getTimeString(java.util.Calendar calendar)
Formats the time of a Calendar instance to a String. The format of the resulting string is the short time format of the default locale.

Parameters:
calendar - the date as a java.util.Calendar
Returns:
date as a formatted string

getTimeString

public static java.lang.String getTimeString(java.util.Calendar calendar,
                                             java.util.Locale locale)
Formats the time of a Calendar instance to a String. The format of the resulting string is the short time format of the given locale.

Parameters:
calendar - the date as a java.util.Calendar
locale - locale
Returns:
date as a formatted string


Domingo Java-API