API
Class

Date ($UI/wxsys/lib/base/date)

使用范围:WX

Contents

class Date ($UI/wxsys/lib/base/date)

常用的日期操作

Constructor Top

  Date ()

Static Properties & Enumerations Top

String DEFAULT_FORMAT

[filed]时间格式常量 = "yyyy/MM/dd hh:mm:ss"

String DEFAULT_FORMAT1

[filed]时间格式常量 = "yyyy-MM-dd hh:mm:ss"

String DEFAULT_FORMAT_SHOT

[filed]时间格式常量 = "yyyy/MM/dd"

String STANDART_FORMAT

[filed]时间格式常量 = "yyyy-MM-ddThh:mm:ss.fffZ"

String STANDART_FORMAT_SHOT

[filed]时间格式常量 = "yyyy-MM-dd"

String UNIT_DAY

[filed]时间单位常量天 = "d"

String UNIT_HOUR

[filed]时间单位常量小时 = "h"

String UNIT_MINUTE

[filed]时间单位常量分钟 = "n"

String UNIT_MONTH

[filed]时间单位常量月 = "m"

String UNIT_QUARTER

[filed]时间单位常量度 = "q"

String UNIT_SECOND

[filed]时间单位常量秒 = "s"

String UNIT_WEEK

[filed]时间单位常量周 = "w"

String UNIT_YEAR

[filed]时间单位常量 年 = "y"

Static Methods Top

Number between (Date start, Date end)
Date decrease (Date datetime, Integer num, String interval)
Number diff (Date start, Date end, String interval)
Date fromString (String str, String format)
Date getFirstDay (Date date)
Date getLastDay (Date date)
Date getServerDatetime ()
Boolean isLeapYear (Date date)
Date now ()
String toString (Date dateTime, String formatStr)

Constructor details Top

public Date ()

常用的日期操作

Static Properties & Enumerations Detail Top

static public String DEFAULT_FORMAT

[filed]时间格式常量 = "yyyy/MM/dd hh:mm:ss"

static public String DEFAULT_FORMAT1

[filed]时间格式常量 = "yyyy-MM-dd hh:mm:ss"

static public String DEFAULT_FORMAT_SHOT

[filed]时间格式常量 = "yyyy/MM/dd"

static public String STANDART_FORMAT

[filed]时间格式常量 = "yyyy-MM-ddThh:mm:ss.fffZ"

static public String STANDART_FORMAT_SHOT

[filed]时间格式常量 = "yyyy-MM-dd"

static public String UNIT_DAY

[filed]时间单位常量天 = "d"

static public String UNIT_HOUR

[filed]时间单位常量小时 = "h"

static public String UNIT_MINUTE

[filed]时间单位常量分钟 = "n"

static public String UNIT_MONTH

[filed]时间单位常量月 = "m"

static public String UNIT_QUARTER

[filed]时间单位常量度 = "q"

static public String UNIT_SECOND

[filed]时间单位常量秒 = "s"

static public String UNIT_WEEK

[filed]时间单位常量周 = "w"

static public String UNIT_YEAR

[filed]时间单位常量 年 = "y"

Static Methods Detail Top

static public Number between (Date start, Date end)

计算两个日期相差几天,和diff很相似,返回永远是正整数

Parameters

Date start

起始日期

Date end

结束日期

Return Value

Number

返回相差几天

static public Date decrease (Date datetime, Integer num, String interval)

根据日期的规则,为给定的日期减去指定的时间量

Parameters

Date datetime

要处理的日期对象

Integer num

减去的时间量

String interval

减去的时间单位,'s'代表秒,'n'代表分钟,'h'代表小时 ,'d'代表天, 'w'代表 周 ,'m'代表月,'q'代表季度,'y'代表年

Return Value

Date

返回日期

static public Number diff (Date start, Date end, String interval)

计算两个日期的差

Parameters

Date start

起始日期

Date end

结束日期

String interval

时间单位,默认是以天为单位,'s'代表秒,'n'代表分钟,'h'代表小时 ,'d'代表天, 'w'代表 周 ,'m'代表月,'q'代表季度,'y'代表年

Return Value

Number

返回结果,如果起始日期小于结束日期返回正整数,否则返回负整数

static public Date fromString (String str, String format)

按照给定的日期格式,把字符串转换成日期对象

Parameters

String str

字符串

String format

日期格式

Return Value

Date

返回日期

static public Date getFirstDay (Date date)

返回月第一天

Parameters

Date date

日期

Return Value

Date

返回月第一天

static public Date getLastDay (Date date)

返回月最后天

Parameters

Date date

日期

Return Value

Date

返回月最后天

static public Date getServerDatetime ()

获取服务端时间

Return Value

Date

获取服务端时间

static public Boolean isLeapYear (Date date)

判断日期是否是闰年

Parameters

Date date

日期

Return Value

Boolean

如果是闰年返回true,否则返回false

static public Date now ()

返回当前时间

Return Value

Date

返回当前时间

static public String toString (Date dateTime, String formatStr)

按照给定的日期格式,把日期对象转换成字符串

Parameters

Date dateTime

要处理的日期对象

String formatStr

日期格式

Return Value

String

返回字符串