com.plumtree.openfoundation.util
Class XPDateFormat

java.lang.Object
  extended by com.plumtree.openfoundation.util.XPDateFormat

public class XPDateFormat
extends java.lang.Object

Collection of date format objects based off of the locale, timezone and if you want a short or long display.


Field Summary
static int DEFAULT
          DEFAULT - display the default date format, which is the same as MEDIUM in java.
static int FULL
          Display the FULL date format.
static int LONG
          Display the LONG date format.
static int MEDIUM
          Display the MEDIUM date format.
static int SHORT
          Display the SHORT format.
 
Method Summary
 void ApplyLocalizedPattern(java.lang.String pattern)
          Apply the given pattern string to this date format, also mapping any formatting characters with a preferred representation in the underlying locale; for example, MM/dd/yy might be mapped to MM-dd-yy.
 void ApplyPattern(java.lang.String pattern)
          Apply the given pattern string to this date format instance, subject to restrictions to make the pattern suitable for cross- platform use on Java and .NET.
 java.lang.String Format(XPDateTime d)
          Returns a formatted date with the selected length, using the default locale and timezone of the server.
 java.lang.String[] GetAmPmStrings()
          Returns an array of AM, PM strings.
static XPDateFormat GetDateInstance(int datetype)
          Create an XPDateFormat object.
static XPDateFormat GetDateInstance(int datetype, XPLocale locale, XPTimeZone timezone)
          Create an XPDateFormat object.
static XPDateFormat GetDateTimeInstance(int datetype, int timetype)
          Create an XPDateFormat object.
static XPDateFormat GetDateTimeInstance(int datetype, int timetype, XPLocale locale, XPTimeZone timezone)
          Create an XPDateFormat object.
static XPDateFormat GetTimeInstance(int timetype)
          Create an XPDateFormat object.
static XPDateFormat GetTimeInstance(int timetype, XPLocale locale, XPTimeZone timezone)
          Create an XPDateFormat object.
 XPDateTime Parse(java.lang.String in)
          Creates an XPDateTime from a string, attempting to parse it according to the instance of the XPDateFormat previously supplied.
 java.lang.String ToPattern()
          Returns the pattern string describing this format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT

public static final int SHORT
Display the SHORT format. SHORT is completely numeric, such as 12.13.52 or 3:30pm.

See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
Display the MEDIUM date format. MEDIUM is longer, such as Jan 12, 1952.

See Also:
Constant Field Values

LONG

public static final int LONG
Display the LONG date format. LONG is longer, such as January 12, 1952 or 3:30:32pm.

See Also:
Constant Field Values

FULL

public static final int FULL
Display the FULL date format. FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.

See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
DEFAULT - display the default date format, which is the same as MEDIUM in java.

See Also:
Constant Field Values
Method Detail

GetDateInstance

public static final XPDateFormat GetDateInstance(int datetype)
Create an XPDateFormat object.

Parameters:
datetype - - the type you want either SHORT or LONG
Returns:
Date instance of the XPDateFormat object

GetDateInstance

public static final XPDateFormat GetDateInstance(int datetype,
                                                 XPLocale locale,
                                                 XPTimeZone timezone)
Create an XPDateFormat object.

Parameters:
datetype - - the type you want either SHORT or LONG
locale - - the locale
timezone - - the timezone
Returns:
Date instance of the XPDateFormat object

GetTimeInstance

public static final XPDateFormat GetTimeInstance(int timetype)
Create an XPDateFormat object.

Parameters:
timetype - - the type you want either SHORT or LONG
Returns:
Time instance of the XPDateFormat object

GetTimeInstance

public static final XPDateFormat GetTimeInstance(int timetype,
                                                 XPLocale locale,
                                                 XPTimeZone timezone)
Create an XPDateFormat object.

Parameters:
timetype - - the type you want either SHORT or LONG
locale - - the locale
timezone - - the timezone
Returns:
Time instance of the XPDateFormat object

GetDateTimeInstance

public static final XPDateFormat GetDateTimeInstance(int datetype,
                                                     int timetype)
Create an XPDateFormat object.

Parameters:
datetype - - the date type you want either SHORT or LONG
timetype - - the time type you want either SHORT or LONG
Returns:
DateTime instance of the date format object

GetDateTimeInstance

public static final XPDateFormat GetDateTimeInstance(int datetype,
                                                     int timetype,
                                                     XPLocale locale,
                                                     XPTimeZone timezone)
Create an XPDateFormat object.

Parameters:
datetype - - the date type you want either SHORT or LONG
timetype - - the time type you want either SHORT or LONG
locale - - the locale
timezone - - the timezone
Returns:
XPDateFormat object for DateTime formatting

Format

public java.lang.String Format(XPDateTime d)
Returns a formatted date with the selected length, using the default locale and timezone of the server.

Parameters:
d - - the date you wish to format.
Returns:
Formatted date string with the default locale and the selected length.

ApplyPattern

public void ApplyPattern(java.lang.String pattern)
Apply the given pattern string to this date format instance, subject to restrictions to make the pattern suitable for cross- platform use on Java and .NET. Caution: Changed behavior in version 3.0.2.0. Both Java and .NET versions now use the same string formatting characters, contrary to previous versions. Supported date formatting characters include the following:
Format Character(s) Meaning Comments
yy yyyy Two- or four-digit year.
d dd Day of month 1-31 or 01-31. Note that ddd and dddd alias internal .NET idioms.
EEE EEEE Day of week, for example Wed or Wednesday Note that these translate to ddd and dddd internally in .NET .
M MM MMM MMMM Month, for example 7 07 Jul or July
h hh Hours 1-12, for example 9 09
H HH Hours 0-24, for example 9 09 or 21 21.
m mm minutes 0-59, for example 3 or 03
s ss seconds 0-59, for example 3 or 03
SSSS Fractions of a second 0000-9999. Translates to ffff internally in .NET.
a AM/PM as indicated per locale. Translates internally to tt in .NET .
z Short time zone name favoring U.S. usage, for example PST. May be ambiguous in world-wide usage. Handled via custom code in XPDateFormat .NET, no direct correspondence.
For example, the pattern "EEE, MMM d, ''yy" would be applied to a date as follows: Wed, July 10, '96.

Parameters:
pattern - - the formatting pattern to be applied.
Throws:
XPIllegalArgumentException - on a pattern containing format characters not mappable to .NET.
Since:
XDK 3.0.2.0 (in current form)

ApplyLocalizedPattern

public void ApplyLocalizedPattern(java.lang.String pattern)
Apply the given pattern string to this date format, also mapping any formatting characters with a preferred representation in the underlying locale; for example, MM/dd/yy might be mapped to MM-dd-yy.

Parameters:
pattern - - the formatting pattern to be applied

GetAmPmStrings

public java.lang.String[] GetAmPmStrings()
Returns an array of AM, PM strings. For e.g., "AM", "PM"

Returns:
an array of AM/PM strings

Parse

public XPDateTime Parse(java.lang.String in)
Creates an XPDateTime from a string, attempting to parse it according to the instance of the XPDateFormat previously supplied. Limitation: Custom date patterns containing a time zone field z can only be parsed if the time zone field is at the end of the string (true of the built-in formats which contain a time zone such as LONG and FULL formats). See XPDateFormat.ApplyPattern. It may be necessary to hand-code a date parser if flexibility in format is needed.
See XPDateFormat.SHORT, XPDateFormat.MEDIUM, XPDateFormat.LONG, XPDateFormat.FULL for options.

Parameters:
in - - the date string to parse
Returns:
parsed datetime
Throws:
XPFormatException - if the input string does not match the underlying date format pattern.

ToPattern

public java.lang.String ToPattern()
Returns the pattern string describing this format.

Returns:
the pattern string


Copyright © 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.