GregorianCalendarFormat Class
根据传入参数,创建对应的 DateTimeFormat 对象
Constructor
Item Index
Methods
- format
- getDateInstance static
- getDateTimeInstance static
- getInstance static
- getTimeInstance static
- parse
Attributes
Methods
format
(
String
-
calender
格式化传入的日历中的时间
Parameters:
-
calender
GregorianCalendar要格式化时间的公历对象
Returns:
Example:
//GregorianCalendar是另一个Class
var gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTime(new Date());
var df = DateTimeFormat.getDateTimeInstance(Style.FULL, Style.FULL);
df.format(gregorianCalendar); //例如现在的:2014年8月14日 星期四 下午05时23分36秒 GMT+0800
var df2 = DateTimeFormat.getDateTimeInstance(Style.FULL, Style.SHORT);
df2.format(gregorianCalendar); //例如现在的:2014年8月14日 星期四 下午5:23
var df3 = DateTimeFormat.getDateInstance(Style.FULL);
df3.format(gregorianCalendar); //例如现在的:2014年8月14日 星期四
getDateInstance
(
String
static
-
dateStyle
-
locale
-
timeZoneOffset
获取当前日期在给定区域和时差及格式下的 DateTimeFormat 对象
Parameters:
Returns:
getDateTimeInstance
(
String
static
-
dateStyle
-
timeStyle
-
locale
-
timeZoneOffset
获取当前日期和时间在给定区域和时差及格式下的DateTimeFormat对象
Parameters:
Returns:
getInstance
(
String
static
-
locale
-
timeZoneOffset
获取当前日期和时间在给定区域和时差下的默认格式化的 DateTimeFormat 对象
Returns:
Example:
//相当于
getDateTimeInstance(DateTimeStyle.SHORT, DateTimeStyle.SHORT, locale, timeZoneOffset)
format后得到的字符串形如: 14-8-14 下午5:44
getTimeInstance
(
String
static
-
timeStyle
-
locale
-
timeZoneOffset
获取当前时间在给定区域和时差及格式下的DateTimeFormat对象
Parameters:
Returns:
parse
(
GregorianCalendar
-
dateStr
解析时间字符串,转换成对应的公历对象
Parameters:
-
dateStr
String要解析的时间字符串
Returns:
Example:
var df = DateTimeFormat.getDateTimeInstance(Style.FULL, Style.FULL);
var str = '2013年7月11日 星期四 下午12时31分19秒 GMT+0800';
var cal = df.parse(str);
Attributes
Style
Object
日期时间格式对象,形式如下:
Style.FULL: yyyy年M月d日 EEEE ahh时mm分ss秒 GMTZ
Style.LONG: yyyy年M月d日 ahh时mm分ss秒
Style.MEDIUM: yyyy-M-d H:mm:ss
Style.SHORT: yy-M-d ah:mm