xlang v5.1 Release
程序设计语言基础库文档
载入中...
搜索中...
未找到
Calendar类 参考

提供日期和时间的操作与管理功能的类。 更多...

Calendar 的协作图:
Collaboration graph

Public 成员函数

静态 Public 成员函数

静态 Public 属性

详细描述

提供日期和时间的操作与管理功能的类。

Calendar类用于表示和操作日历时间,包括年、月、日、时、分、秒等字段,并支持时区和夏令时偏移。 提供了设置、获取、比较、清除时间等方法,以及静态常量用于标识各种日历字段和样式。

在文件 Calendar.x8 行定义.

构造及析构函数说明

◆ Calendar()

Calendar ( )

构造一个新的Calendar对象,初始化为当前时间。

成员函数说明

◆ clear() [1/2]

void clear ( )

清除所有字段的值。

◆ clear() [2/2]

void clear ( int  field)

清除指定字段的值。

参数
field字段常量。

◆ compareTo()

int compareTo ( Calendar  another)

比较两个Calendar对象的时间先后。

参数
another另一个Calendar对象。
返回
比较结果:负值表示早于,零表示相等,正值表示晚于。

◆ finalize()

void finalize ( )

释放资源,进行对象终结。

◆ get()

int get ( int  field)

获取指定字段的值。

参数
field字段常量,如YEAR、MONTH等。
返回
字段对应的值。

◆ getInstance() [1/2]

static final Calendar getInstance ( )
static

获取默认的Calendar实例。

返回
默认Calendar对象。

◆ getInstance() [2/2]

static final Calendar getInstance ( int  offset)
static

获取指定时区的Calendar实例。

参数
offset时区偏移量(单位:毫秒)。
返回
指定时区的Calendar对象。

◆ getTime()

String getTime ( )

获取当前时间的字符串表示。

返回
当前时间的字符串。

◆ getTimeInMillis()

long getTimeInMillis ( )

获取当前时间(毫秒)。

返回
当前时间,单位为毫秒。

◆ getTimeZoneOffset()

int getTimeZoneOffset ( )

获取时区偏移量。

返回
时区偏移量(单位:毫秒)。

◆ set() [1/3]

void set ( int  field,
int  value 
)

设置指定字段的值。

参数
field字段常量。
value要设置的值。

◆ set() [2/3]

void set ( int  year,
int  month,
int  date 
)

设置年、月、日。

参数
year年份。
month月份。
date日期。

◆ set() [3/3]

void set ( int  year,
int  month,
int  date,
int  hourOfDay,
int  minute,
int  second 
)

设置年、月、日、时、分、秒。

参数
year年份。
month月份。
date日期。
hourOfDay小时(24小时制)。
minute分钟。
second秒。

◆ setTime()

void setTime ( String  date,
String  format 
)

通过字符串设置时间。

参数
date日期字符串。
format格式字符串。

◆ setTimeInMillis()

void setTimeInMillis ( long  millis)

设置时间(毫秒)。

参数
millis要设置的时间,单位为毫秒。

◆ setTimeZoneOffset()

void setTimeZoneOffset ( int  offset)

设置时区偏移量。

参数
offset时区偏移量(单位:毫秒)。

◆ toString()

String toString ( )

获取Calendar对象的字符串表示。

返回
字符串表示。

结构体成员变量说明

◆ ALL_STYLES

const int ALL_STYLES
static

所有样式常量。

在文件 Calendar.x92 行定义.

◆ AM

const int AM
static

上午常量。

在文件 Calendar.x88 行定义.

◆ AM_PM

const int AM_PM
static

上午/下午字段常量。

在文件 Calendar.x30 行定义.

◆ APRIL

const int APRIL
static

四月常量。

在文件 Calendar.x68 行定义.

◆ AUGUST

const int AUGUST
static

八月常量。

在文件 Calendar.x76 行定义.

◆ DATE

const int DATE
static

日期字段常量。

在文件 Calendar.x20 行定义.

◆ DAY_OF_MONTH

const int DAY_OF_MONTH
static

月中的天字段常量。

在文件 Calendar.x22 行定义.

◆ DAY_OF_WEEK

const int DAY_OF_WEEK
static

星期字段常量。

在文件 Calendar.x26 行定义.

◆ DAY_OF_WEEK_IN_MONTH

const int DAY_OF_WEEK_IN_MONTH
static

月中的星期字段常量。

在文件 Calendar.x28 行定义.

◆ DAY_OF_YEAR

const int DAY_OF_YEAR
static

年中的天字段常量。

在文件 Calendar.x24 行定义.

◆ DECEMBER

const int DECEMBER
static

十二月常量。

在文件 Calendar.x84 行定义.

◆ DST_OFFSET

const int DST_OFFSET
static

夏令时偏移字段常量。

在文件 Calendar.x44 行定义.

◆ ERA

const int ERA
static

纪元字段常量。

在文件 Calendar.x10 行定义.

◆ FEBRUARY

const int FEBRUARY
static

二月常量。

在文件 Calendar.x64 行定义.

◆ FIELD_COUNT

const int FIELD_COUNT
static

字段总数常量。

在文件 Calendar.x46 行定义.

◆ FRIDAY

const int FRIDAY
static

星期五常量。

在文件 Calendar.x58 行定义.

◆ HOUR

const int HOUR
static

小时字段常量(12小时制)。

在文件 Calendar.x32 行定义.

◆ HOUR_OF_DAY

const int HOUR_OF_DAY
static

小时字段常量(24小时制)。

在文件 Calendar.x34 行定义.

◆ JANUARY

const int JANUARY
static

一月常量。

在文件 Calendar.x62 行定义.

◆ JULY

const int JULY
static

七月常量。

在文件 Calendar.x74 行定义.

◆ JUNE

const int JUNE
static

六月常量。

在文件 Calendar.x72 行定义.

◆ LONG

const int LONG
static

长样式常量。

在文件 Calendar.x98 行定义.

◆ LONG_FORMAT

const int LONG_FORMAT
static

长格式样式常量。

在文件 Calendar.x106 行定义.

◆ LONG_STANDALONE

const int LONG_STANDALONE
static

长独立样式常量。

在文件 Calendar.x110 行定义.

◆ MARCH

const int MARCH
static

三月常量。

在文件 Calendar.x66 行定义.

◆ MAY

const int MAY
static

五月常量。

在文件 Calendar.x70 行定义.

◆ MILLISECOND

const int MILLISECOND
static

毫秒字段常量。

在文件 Calendar.x40 行定义.

◆ MINUTE

const int MINUTE
static

分钟字段常量。

在文件 Calendar.x36 行定义.

◆ MONDAY

const int MONDAY
static

星期一常量。

在文件 Calendar.x50 行定义.

◆ MONTH

const int MONTH
static

月份字段常量。

在文件 Calendar.x14 行定义.

◆ NARROW_FORMAT

const int NARROW_FORMAT
static

狭窄格式样式常量。

在文件 Calendar.x100 行定义.

◆ NARROW_STANDALONE

const int NARROW_STANDALONE
static

狭窄独立样式常量。

在文件 Calendar.x102 行定义.

◆ NOVEMBER

const int NOVEMBER
static

十一月常量。

在文件 Calendar.x82 行定义.

◆ OCTOBER

const int OCTOBER
static

十月常量。

在文件 Calendar.x80 行定义.

◆ PM

const int PM
static

下午常量。

在文件 Calendar.x90 行定义.

◆ SATURDAY

const int SATURDAY
static

星期六常量。

在文件 Calendar.x60 行定义.

◆ SECOND

const int SECOND
static

秒字段常量。

在文件 Calendar.x38 行定义.

◆ SEPTEMBER

const int SEPTEMBER
static

九月常量。

在文件 Calendar.x78 行定义.

◆ SHORT

const int SHORT
static

简短样式常量。

在文件 Calendar.x96 行定义.

◆ SHORT_FORMAT

const int SHORT_FORMAT
static

简短格式样式常量。

在文件 Calendar.x104 行定义.

◆ SHORT_STANDALONE

const int SHORT_STANDALONE
static

简短独立样式常量。

在文件 Calendar.x108 行定义.

◆ STANDALONE_MASK

const int STANDALONE_MASK
static

独立样式掩码常量。

在文件 Calendar.x94 行定义.

◆ SUNDAY

const int SUNDAY
static

星期日常量。

在文件 Calendar.x48 行定义.

◆ THURSDAY

const int THURSDAY
static

星期四常量。

在文件 Calendar.x56 行定义.

◆ TUESDAY

const int TUESDAY
static

星期二常量。

在文件 Calendar.x52 行定义.

◆ UNDECIMBER

const int UNDECIMBER
static

第十三月常量(用于某些历法)。

在文件 Calendar.x86 行定义.

◆ WEDNESDAY

const int WEDNESDAY
static

星期三常量。

在文件 Calendar.x54 行定义.

◆ WEEK_OF_MONTH

const int WEEK_OF_MONTH
static

月中的周字段常量。

在文件 Calendar.x18 行定义.

◆ WEEK_OF_YEAR

const int WEEK_OF_YEAR
static

年中的周字段常量。

在文件 Calendar.x16 行定义.

◆ YEAR

const int YEAR
static

年份字段常量。

在文件 Calendar.x12 行定义.

◆ ZONE_OFFSET

const int ZONE_OFFSET
static

时区偏移字段常量。

在文件 Calendar.x42 行定义.