jsbeans

jsbeans  1.0.0

jsbeans > jsbeans > jsbeans.SimpleDateFormat
Search:
 
Filters

Class jsbeans.SimpleDateFormat

Pure javascript implementaion of java.text.SimpleDateFormat.
Letter | Date or Time Component | Presentation | Examples
G | Era designator | Text | AD
y | Year | Year | 1996; 96
M | Month in year | Month | July; Jul; 07
w | Week in year | Number | 27
W | Week in month | Number | 2
D | Day in year | Number | 189
d | Day in month | Number | 10
F | Day of week in month | Number | 2
E | Day in week | Text | Tuesday; Tue
a | Am/pm marker | Text | PM
H | Hour in day (0-23) | Number | 0
k | Hour in day (1-24) | Number | 24
K | Hour in am/pm (0-11) | Number | 0
h | Hour in am/pm (1-12) | Number | 12
m | Minute in hour | Number | 30
s | Second in minute | Number | 55
S | Millisecond | Number | 978
z | Time zone | General time zone | Pacific Standard Time; PST; GMT-08:00
Z | Time zone | RFC 822 time zone | -0800

Constructor

jsbeans.SimpleDateFormat ( [pattern] )
Parameters:
[pattern] <String> default "MM/dd/yyyy hh:mm"

Methods

addLocale

void addLocale ( locale )
A new Locale must be in the format
{
name: 'xx'// two chars, e.g. 'fr'
months: ['first month', 'second month',  ...]// month's names
days: ['first day starting from sunday', 'day after sunday', ...]//day's names starting from sunday
}
Parameters:
locale <JSON>
Returns: void

applyPattern

void applyPattern ( pattern )
Applies the given {@param} pattern string to this date format.
Parameters:
pattern <String>
Returns: void

format

String format ( date )
Returns a formatted string starting from {@param} date based on current pattern.
Parameters:
date <Date> the date to format
Returns: String
the formatted date

getAvailableLocales

static void getAvailableLocales ( )
Returns the available locales as set by jsbeans.SimpleDateFormat.LOCALES and, eventually, other than defaults.
Returns: void

getDayName

String getDayName ( dayZeroBased )
Returns the localized day's name from its index.
Parameters:
dayZeroBased <Integer> the index of day
Returns: String
the localized day's name

getLocale

String getLocale ( )
Returns the current locale
Returns: String

getMonthName

String getMonthName ( monthZeroBased )
Returns the localized month's name from its index.
Parameters:
monthZeroBased <Integer> the index of month
Returns: String
the localized month's name

loadLocale

static void loadLocale ( localeName , [scriptPrefixSlashEnded] )
Loads a script tag: <script type="text/javascript" src="{@param}scriptPrefixSlashEnded/SimpleDateFormatLocale_{@param}localeName.js"> </script>.
As a choice of design we do not throws exceptions so no feedback will be return to user in case of error
Parameters:
localeName <String>
[scriptPrefixSlashEnded] <String> optional url prefix. Default ""
Returns: void

setLocale

void setLocale ( locale )
Sets {@param} locale to this date format.
The {@param} locale must be loaded first, otherwise "en" will be used.
Parameters:
locale <String>
Returns: void

Configuration Attributes

jsbeans.SimpleDateFormat.DAY_NAMES - static object

Array of day names for default locales.

jsbeans.SimpleDateFormat.LOCALES - static object

Array of default locales: english ('en') and italian ('it')

jsbeans.SimpleDateFormat.MONTH_NAMES - static object

Array of month names for default locales.


Copyright © 2016 Francesco Mele. All rights reserved.