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

Name Type Optional Default Descripton
sPattern String A pattern describing the date format.
sLanguage String checked Optional string describing the locale

Properties

Name Type get set Descripton
dateFormatSymbols BiDateFormatSymbols checked checked The date format symbols used to define how to parse and format strings and dates
lenient Boolean checked checked When 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.
localizedPattern String checked checked The pattern using localized pattern characters
pattern String checked checked The pattern to use when formatting and parsing

Methods

Name Description
format This takes a date object and outputs a string formatted according to the provided pattern
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.

Events

None.

Static Methods

Name Description
getDateInstance Creates a new BiDateFormat object that uses a date pattern.
getDateTimeInstance Creates a new BiDateFormat object that uses a date time pattern.
getTimeInstance Creates a new BiDateFormat object that uses a time pattern.

Static Fields

Name Type Descripton
LONG String Constant for long date format pattern
MEDIUM String Constant for medium date format pattern
SHORT String Constant 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

Name Type Optional Default Descripton
oDate Date The 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

Name Type Optional Default Descripton
sDate String The 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

Name Type Optional Default Descripton
sType String Whether to use a short, medium or long date pattern
sLanguage String checked Optional 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

Name Type Optional Default Descripton
sType String Whether to use a short, medium or long date time pattern
sLanguage String checked Optional string identifying the locale.

Return Type

BiDateFormat

getTimeInstance

Creates a new BiDateFormat object that uses a time pattern.

Syntax

BiDateFormat
 .
 getTimeInstance
 (
 sType
 [
 ,sLanguage
 ]
 
 )
 

Parameters

Name Type Optional Default Descripton
sType String Whether to use a short, medium or long time pattern
sLanguage String checked Optional string identifying the locale.

Return Type

BiDateFormat