com.filenet.wcm.toolkit.server.util

Class WcmDateUtil

  1. java.lang.Object
  2. extended bycom.filenet.wcm.toolkit.server.util.WcmDateUtil

  1. public class WcmDateUtil
  2. extends java.lang.Object
Various utility functions for working with dates.

The W3C DateTime format extends the ISO 8601 Date format:
YYYY-MM-DDThh:mm:ss[.sss][TimeZone] or YYYY-MM-DD[TimeZone]

where:

YYYY represents a 4-digit year.
MM represents a 2-digit month in the range of 01-12.
DD represents a 2-digit day in the range 01-31.
T is optional. If present, the format includes date and time, otherwise date only.
hh represents a 2-digit hour in the range of 00-23
mm represents a 2-digit minute in the range of 00-59
ss represents a 2-digit second in the range of 00-59
.sss is optional and represents milliseconds.
TimeZone is optional. It could be letter Z, which represents GMT, or time differences between local time and GMT, for example, in 1999-05-31T13:20:00-05:00, -05:00 is for EST. If it is not present, the time defaults to LOCAL TIME ZONE!

For reference, see http://www.w3.org/TR/NOTE-datetime


Field Summary

Modifier and Type Field and Description
  1. static
  2. java.util.TimeZone
TIME_ZONE_GMT

Method Summary

Modifier and Type Method and Description
  1. static
  2. boolean
compareDates(java.lang.String isoDateOne,java.lang.String isoDateTwo)
Compares dates and returns true if they are equal
  1. static
  2. java.lang.String
convertDateToW3CDate(java.util.Calendar cal,boolean bDateOnly)
Converts Date object into W3C-date-formatted string.
  1. static
  2. java.lang.String
convertDateToW3CDate(java.util.Date date,boolean bDateOnly)
Deprecated. Use convertDateToW3CDate(Calendar cal, boolean bDateOnly)
  1. static
  2. java.util.Calendar
convertW3CDateToCalendar(java.lang.String str,boolean hyphenated)
  1. static
  2. java.util.Calendar
convertW3CDateToCalendar(java.lang.String str,boolean hyphenated,java.util.TimeZone defaultTimeZone)
  1. static
  2. java.util.Date
convertW3CDateToDate(java.lang.String str)
Parses the string with W3C-formatted date and returns java Date object.
  1. static
  2. java.util.Date
convertW3CDateToDate(java.lang.String str,boolean hyphenated)
Parses the string with W3C-formatted date and returns java Date object.
  1. static
  2. java.lang.String
formatCompressedISODateTime(java.lang.String month,java.lang.String day,java.lang.String year)
Puts the date in compressed W3C format without validation.
  1. static
  2. java.lang.String
formatDateTime(java.lang.String locale,java.lang.String isoDateTime,java.lang.String dateFormat,java.lang.String timeFormat)
Formats a date using separate format strings for date and time format
  1. static
  2. java.lang.String
formatISODateTime(java.lang.String month,java.lang.String day,java.lang.String year)
Puts the date in W3C format without validation.
  1. static
  2. java.lang.String
getFormattedDate(java.util.Locale locale,java.lang.String isoDateTime)
Get the formatted date corresponding to the specified W3C formatted date/time using the specified locale.
  1. static
  2. java.lang.String
getFormattedDate(java.lang.String locale,java.lang.String isoDateTime)
Get the formatted date corresponding to the specified W3C formatted date/time using the specified locale.
  1. static
  2. java.lang.String
getFormattedDateTime(java.util.Locale locale,java.lang.String isoDateTime)
Get the formatted date/time corresponding to the specified W3C formatted date/time using the specified locale.
  1. static
  2. java.lang.String
getFormattedDateTime(java.lang.String locale,java.lang.String isoDateTime)
Get the formatted date/time corresponding to the specified W3C formatted date/time using the specified locale.
  1. static
  2. java.lang.String
localISODateTime(java.lang.String isoDateTime)
Returns the date in W3C format shifted from GMT to local time.
  1. static
  2. java.util.Date
parseCompressedISODateTimeNoShift(java.lang.String isoDateTime)
Parses an W3C-formatted date String into a Date object.
  1. static
  2. java.util.Date
parseISODateTimeNoShift(java.lang.String isoDateTime)
Parses an W3C-formatted date String into a Date object.
  1. static
  2. java.lang.String
validateCompressedISODateTime(java.lang.String newDate,java.lang.String min,java.lang.String max)
Validates a date and returns it in GMT time zone.
  1. static
  2. java.lang.String
validateISODateTime(java.lang.String newDate,java.lang.String min,java.lang.String max)
Validates a date and returns it in GMT time zone.
  1. static
  2. java.lang.String
validateISODateTimeNoShift(java.lang.String input,java.lang.String min,java.lang.String max,java.util.Locale locale,java.util.TimeZone tz)
Validates a date for min and max.
  1. static
  2. boolean
validateMonthDayYear(int month,int day,int year)
Validates the month, day, and year values of a date.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

TIME_ZONE_GMT

  1. public static final java.util.TimeZone TIME_ZONE_GMT

Method Detail

formatDateTime

  1. public static java.lang.String formatDateTime( java.lang.String locale,
  2. java.lang.String isoDateTime,
  3. java.lang.String dateFormat,
  4. java.lang.String timeFormat)
  5. throws java.lang.Exception
Formats a date using separate format strings for date and time format
Parameters:
locale - encoded locale
isoDateTime - date/time in iso gmt
dateFormat -
timeFormat -
Returns:
formatted date/time as a String
Throws:
java.lang.Exception

getFormattedDate

  1. public static java.lang.String getFormattedDate( java.util.Locale locale,
  2. java.lang.String isoDateTime)
  3. throws java.lang.Exception
Get the formatted date corresponding to the specified W3C formatted date/time using the specified locale.
Parameters:
locale - The Locale object specifying the locale
isoDateTime - The W3C date/time value in GTM time zone
Returns:
The formatted date/time as a String in LOCAL time zone
Throws:
java.lang.Exception

getFormattedDate

  1. public static java.lang.String getFormattedDate( java.lang.String locale,
  2. java.lang.String isoDateTime)
  3. throws java.lang.Exception
Get the formatted date corresponding to the specified W3C formatted date/time using the specified locale.
Parameters:
locale - The String locale value as specified by WcmUi.encodeLocale
isoDateTime - The W3C date/time value in GTM time zone
Returns:
The formatted date/time as a String in LOCAL time zone
Throws:
java.lang.Exception

getFormattedDateTime

  1. public static java.lang.String getFormattedDateTime( java.util.Locale locale,
  2. java.lang.String isoDateTime)
  3. throws java.lang.Exception
Get the formatted date/time corresponding to the specified W3C formatted date/time using the specified locale.
Parameters:
locale - The Locale object specifying the locale
isoDateTime - The W3C date/time value in GMT time zone
Returns:
The formatted date/time as a String in LOCAL time zone
Throws:
java.lang.Exception

getFormattedDateTime

  1. public static java.lang.String getFormattedDateTime( java.lang.String locale,
  2. java.lang.String isoDateTime)
  3. throws java.lang.Exception
Get the formatted date/time corresponding to the specified W3C formatted date/time using the specified locale.
Parameters:
locale - The String locale value as specified by WcmUi.encodeLocale
isoDateTime - The W3C date/time value in GMT time zone
Returns:
The formatted date/time as a String in LOCAL time zone
Throws:
java.lang.Exception

localISODateTime

  1. public static java.lang.String localISODateTime( java.lang.String isoDateTime)
  2. throws java.lang.Exception
Returns the date in W3C format shifted from GMT to local time.
Parameters:
isoDateTime - The W3C date/time value in GMT time zone
Returns:
The W3C date/time value in LOCAL time zone
Throws:
java.lang.Exception

formatISODateTime

  1. public static java.lang.String formatISODateTime( java.lang.String month,
  2. java.lang.String day,
  3. java.lang.String year)
Puts the date in W3C format without validation. Pads with leading zeros as needed. Caller should make sure the month and day are 2 chars or less, and the year is 4 chars or less.
Parameters:
month - The month, 2 chars or less
day - The day, 2 chars or less
year - The year, 4 chars or less
Returns:
The date in W3C format without validation

formatCompressedISODateTime

  1. public static java.lang.String formatCompressedISODateTime( java.lang.String month,
  2. java.lang.String day,
  3. java.lang.String year)
Puts the date in compressed W3C format without validation. Pads with leading zeros as needed. Caller should make sure the month and day are 2 chars or less, and the year is 4 chars or less.
Parameters:
month - The month, 2 chars or less
day - The day, 2 chars or less
year - The year, 4 chars or less
Returns:
The date in compressed W3C format without validation

validateISODateTimeNoShift

  1. public static java.lang.String validateISODateTimeNoShift( java.lang.String input,
  2. java.lang.String min,
  3. java.lang.String max,
  4. java.util.Locale locale,
  5. java.util.TimeZone tz)
  6. throws java.lang.Exception
Validates a date for min and max. Does not do any time conversion.
Parameters:
input - The date to validate in ISO format, GMT time.
min - The minimum date value in W3C format
max - The maximum date value in W3C format
Throws:
java.lang.Exception

validateISODateTime

  1. public static java.lang.String validateISODateTime( java.lang.String newDate,
  2. java.lang.String min,
  3. java.lang.String max)
  4. throws java.lang.Exception
Validates a date and returns it in GMT time zone.
Parameters:
newDate - The date to validate in W3C format, local time
min - The minimum date value in W3C format
max - The maximum date value in W3C format
Returns:
The validated date in W3C format, GMT time
Throws:
java.lang.Exception

validateCompressedISODateTime

  1. public static java.lang.String validateCompressedISODateTime( java.lang.String newDate,
  2. java.lang.String min,
  3. java.lang.String max)
  4. throws java.lang.Exception
Validates a date and returns it in GMT time zone.
Parameters:
newDate - The date to validate in W3C format, local time
min - The minimum date value in W3C format
max - The maximum date value in W3C format
Returns:
The validated date in W3C format, GMT time
Throws:
java.lang.Exception

validateMonthDayYear

  1. public static boolean validateMonthDayYear( int month,
  2. int day,
  3. int year)
Validates the month, day, and year values of a date.
Parameters:
month - Integer holding the month
day - Integer holding the day
year - Integer holding the year
Returns:
True if the date validates successfully; False otherwise

parseISODateTimeNoShift

  1. public static java.util.Date parseISODateTimeNoShift( java.lang.String isoDateTime)
  2. throws java.text.ParseException
Parses an W3C-formatted date String into a Date object. W3C-formatted date is NOT time shifted.
Parameters:
isoDateTime - The W3C formatted date/time
Returns:
An instance of Date object, un-shifted
Throws:
java.text.ParseException

parseCompressedISODateTimeNoShift

  1. public static java.util.Date parseCompressedISODateTimeNoShift( java.lang.String isoDateTime)
  2. throws java.text.ParseException
Parses an W3C-formatted date String into a Date object. W3C-formatted date is NOT time shifted.
Parameters:
isoDateTime - The W3C formatted date/time
Returns:
An instance of Date object, un-shifted
Throws:
java.text.ParseException

convertDateToW3CDate

  1. public static java.lang.String convertDateToW3CDate( java.util.Date date,
  2. boolean bDateOnly)
Deprecated. Use convertDateToW3CDate(Calendar cal, boolean bDateOnly)

convertDateToW3CDate

  1. public static java.lang.String convertDateToW3CDate( java.util.Calendar cal,
  2. boolean bDateOnly)
Converts Date object into W3C-date-formatted string.
Parameters:
cal - an object of type java.util.date
bDateOnly - This is a pass-in parameter. If true, the returned W3C format string only contains date, otherwise if false, the returned string contains both date and time.
Returns:
a W3C-date-formatted string

compareDates

  1. public static boolean compareDates( java.lang.String isoDateOne,
  2. java.lang.String isoDateTwo)
Compares dates and returns true if they are equal
Parameters:
isoDateOne - First date to compare
isoDateTwo - Second date to compare
Returns:
True if dates are equal

convertW3CDateToDate

  1. public static java.util.Date convertW3CDateToDate( java.lang.String str)
  2. throws WcmException
Parses the string with W3C-formatted date and returns java Date object.
Parameters:
str - a String object containing an W3C-date-formatted string.
Returns:
Date object
Throws:
WcmException - if the input is not in the right format.

convertW3CDateToCalendar

  1. public static java.util.Calendar convertW3CDateToCalendar( java.lang.String str,
  2. boolean hyphenated)
  3. throws WcmException
Throws:

convertW3CDateToCalendar

  1. public static java.util.Calendar convertW3CDateToCalendar( java.lang.String str,
  2. boolean hyphenated,
  3. java.util.TimeZone defaultTimeZone)
  4. throws WcmException
Throws:

convertW3CDateToDate

  1. public static java.util.Date convertW3CDateToDate( java.lang.String str,
  2. boolean hyphenated)
  3. throws WcmException
Parses the string with W3C-formatted date and returns java Date object.
Parameters:
str - a String object containing an W3C-date-formatted string.
hyphenated - Specify true to indicate date/time format either "2004-05-01..." or "20040501..."
Returns:
Date object
Throws:
WcmException - if the input is not in the right format.