OverviewSingleDeprecatedPropertiesEventsXSL Parameters

jsx3.util

class DateFormat

Object
->jsx3.lang.Object
  ->jsx3.util.DateFormat

class DateFormat
extends jsx3.lang.Object
Formats and parses dates according to a token-based string format. This class is fully localized.

An instance of this class is defined by its format, which is a string conforming to the following syntax: The following tokens are supported: Each token has a type, which determines how it is formatted and parsed. The token types are:

Since:

3.2

Field Summary
static int
FULL
Type for a full-length localized date or time format.
static int
LONG
Type for a long localized date or time format.
static int
MEDIUM
Type for a medium-length localized date or time format.
static int
SHORT
Type for a short localized date or time format.
Constructor Summary
void
init(strFormat : String, objLocale : jsx3.util.Locale)
The instance initializer.
Method Summary
String
format(objDate : Number | Object | Date)
Formats a date according to this date format.
static jsx3.util.DateFormat
getDateInstance(intType : int, objLocale : jsx3.util.Locale)
Returns a date format localized for a particular locale.
static jsx3.util.DateFormat
getDateTimeInstance(intDateType : int, intTimeType : int, objLocale : jsx3.util.Locale)
Returns a date and time format localized for a particular locale.
String
Returns the format passed to the constructor.
jsx3.util.Locale
static jsx3.util.DateFormat
getTimeInstance(intType : int, objLocale : jsx3.util.Locale)
Returns a time format localized for a particular locale.
int
getTimeZoneOffset(objDate : Date)
Returns the timezone offset of this date format.
Date
parse(strDate : String)
Parses a string according to this date format and returns the resulting date.
void
void
setTimeZoneOffset(intMinutes : int)
Sets the timezone offset of this date format.
String
Returns a string representation of this date format.
Methods Inherited From jsx3.lang.Object
clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf
Field Detail

FULL

static final int FULL
Type for a full-length localized date or time format.

LONG

static final int LONG
Type for a long localized date or time format.

MEDIUM

static final int MEDIUM
Type for a medium-length localized date or time format.

SHORT

static final int SHORT
Type for a short localized date or time format.
Constructor Detail

init

void init(strFormat : String, objLocale : jsx3.util.Locale)
The instance initializer. Instances of this class are immutable.

Parameters:

strFormatthe date format.
objLocalethe locale with which to format and parse dates. If this parameter is not provided the default system locale is used.

Throws:

{jsx3.lang.Exception}if strFormat cannot be parsed.

See Also:

Date Format Syntax
Method Detail

format

String format(objDate : Number | Object | Date)
Formats a date according to this date format.

Parameters:

objDatethe date to format.

Returns:

the formatted date.  

getDateInstance

static jsx3.util.DateFormat getDateInstance(intType : int, objLocale : jsx3.util.Locale)
Returns a date format localized for a particular locale.

Parameters:

intTypeSHORT, MEDIUM, LONG, or FULL
objLocalethe locale for which to return a format. If this parameter is not provided, the default system locale is used.

Returns:

 

getDateTimeInstance

static jsx3.util.DateFormat getDateTimeInstance(intDateType : int, intTimeType : int, objLocale : jsx3.util.Locale)
Returns a date and time format localized for a particular locale.

Parameters:

intDateTypeSHORT, MEDIUM, LONG, or FULL
intTimeTypeSHORT, MEDIUM, LONG, or FULL
objLocalethe locale for which to return a format. If this parameter is not provided, the default system locale is used.

Returns:

 

getFormat

String getFormat()
Returns the format passed to the constructor.

Returns:

 

getLocale

jsx3.util.Locale getLocale()

Returns:

 

getTimeInstance

static jsx3.util.DateFormat getTimeInstance(intType : int, objLocale : jsx3.util.Locale)
Returns a time format localized for a particular locale.

Parameters:

intTypeSHORT, MEDIUM, LONG, or FULL
objLocalethe locale for which to return a format. If this parameter is not provided, the default system locale is used.

Returns:

 

getTimeZoneOffset

int getTimeZoneOffset(objDate : Date)
Returns the timezone offset of this date format. This is the difference between GMT and the local time of this date format, in minutes. For example, Pacific Standard Time is -480 (-08h * 60). If the timezone offset has been set explicitly with setTimeZoneOffset(), that value is returned.

Since the timezone offset may change over the year for Daylight Savings Time, this method takes a Date argument, objDate. All dates are created with the timezone offset of the host browser's timezone, adjusted for Daylight Savings Time. Therefore, if the timezone offset of this date format has not been set explicitly, the timezone offset is determined from the objDate parameter, or, if that is not provided, from the current time.

Parameters:

objDatethe date for which to return the timezone offset.

Returns:

the timezone offset in minutes.  

parse

Date parse(strDate : String)
Parses a string according to this date format and returns the resulting date. If strDate does not conform to this date format, an exception is thrown.

The default date for the purposes of this method is 1-Jan-1970 12:00AM, local time. If any date fields are omitted from this format, the date returned by this method will inherit those fields from the default date.

Parameters:

strDatethe string to parse.

Throws:

{jsx3.lang.Exception}if strDate cannot be parsed according to this format.

Returns:

the parsed date. 

setLocale

void setLocale(objLocale : jsx3.util.Locale)

Parameters:

objLocale

setTimeZoneOffset

void setTimeZoneOffset(intMinutes : int)
Sets the timezone offset of this date format. The default value is the value for the local time.

Parameters:

intMinutesthe timezone offset in minutes.

See Also:

getTimeZoneOffset()

toString

String toString()
Returns a string representation of this date format.

Returns:

 

Overrides:

toString in jsx3.lang.Object