BiDateFormat

This class is used to format and parse dates. It is based on the Java class SimpleDateFormat.

This class extends BiObject and therefore all methods and fields available for BiObject are also available for BiDateFormat .

Constructor

new BiDateFormat ( sPattern,sLanguage )

Parameters

NameTypeOptionalDefaultDescripton
sPatternStringA pattern describing the date format.
sLanguageStringOptional string describing the locale

Properties

NameTypegetsetDescripton
dateFormatSymbolsBiDateFormatSymbolscheckedcheckedThe date format symbols used to define how to parse and format strings and dates
lenientBooleancheckedcheckedWhen this is true parsing will try to parse the string even though it does not correctly match the given pattern. For example it will try to use the Javascript Date parse method.
localizedPatternStringcheckedcheckedThe pattern using localized pattern characters
patternStringcheckedcheckedThe pattern to use when formatting and parsing

Methods

NameDescription
formatThis takes a date object and outputs a string formatted according to the provided pattern
parseThis takes a string describing the date and uses the current pattern to parse it to javascript date object. If lenient is true this will also try to parse the string even if it does not match the pattern.

If this fails an exception will be thrown.

Events

None.

Static Methods

NameDescription
getDateInstanceCreates a new BiDateFormat object that uses a date pattern.
getDateTimeInstanceCreates a new BiDateFormat object that uses a date time pattern.
getTimeInstanceCreates a new BiDateFormat object that uses a time pattern.

Static Fields

NameTypeDescripton
LONGStringConstant for long date format pattern
MEDIUMStringConstant for medium date format pattern
SHORTStringConstant for short date format pattern

Remarks

Some limitations compared to the java class apply. For example where Java uses a Locale class Bindows uses a string. The formatting and parsing of the timezone are limited to the formats GMT+/-HHmm ('z') or +/-HHmm ('Z'). 'w' (week in year), 'W' (week in month) and 'D' (day in year) are not supported.

Method Details

format

This takes a date object and outputs a string formatted according to the provided pattern

Syntax

object.format ( oDate )

Parameters

NameTypeOptionalDefaultDescripton
oDateDateThe date to format

Return Type

String

parse

This takes a string describing the date and uses the current pattern to parse it to javascript date object. If lenient is true this will also try to parse the string even if it does not match the pattern.

If this fails an exception will be thrown.

Syntax

object.parse ( sDate )

Parameters

NameTypeOptionalDefaultDescripton
sDateStringThe string describing the date

Return Type

Date

Static Method Details

getDateInstance

Creates a new BiDateFormat object that uses a date pattern.

Syntax

BiDateFormat . getDateInstance ( sType,sLanguage )

Parameters

NameTypeOptionalDefaultDescripton
sTypeStringWhether to use a short, medium or long date pattern
sLanguageStringOptional string identifying the locale.

Return Type

BiDateFormat

getDateTimeInstance

Creates a new BiDateFormat object that uses a date time pattern.

Syntax

BiDateFormat . getDateTimeInstance ( sType,sLanguage )

Parameters

NameTypeOptionalDefaultDescripton
sTypeStringWhether to use a short, medium or long date time pattern
sLanguageStringOptional string identifying the locale.

Return Type

BiDateFormat

getTimeInstance

Creates a new BiDateFormat object that uses a time pattern.

Syntax

BiDateFormat . getTimeInstance ( sType,sLanguage )

Parameters

NameTypeOptionalDefaultDescripton
sTypeStringWhether to use a short, medium or long time pattern
sLanguageStringOptional string identifying the locale.

Return Type

BiDateFormat