java3的 DateUtils方法

暂时先上传这些,后续有机会再整理,该DateUtils为org.apache.commons.lang3.time.DateUtils

序号

方法名

返回值

英文注释

文字注释

1

addDays(Date date, int amount)

 

static Date

Adds a number of days to a date returning a new object

在日期‘天’上添加数字amount(可为负数),返回日期类型

2

addHours(Date date, int amount)

 

static Date

Adds a number of hours to a date returning a new object

在日期‘小时’上添加数字amount(可为负数),返回日期类型

3

addMilliseconds(Date date, int amount)

 

static Date

Adds a number of milliseconds to a date returning a new object.

在日期‘毫秒’上添加数字amount(可为负数),返回日期类型

4

addMinutes(Date date, int amount)

 

static Date

Adds a number of minutes to a date returning a new object

在日期‘分钟’上添加数字amount(可为负数),返回日期类型

5

addMonths(Date date, int amount)

static Date

Adds a number of months to a date returning a new object

在日期‘月份’上添加数字amount(可为负数),返回日期类型

6

addSeconds(Date date, int amount)

 

static Date

Adds a number of seconds to a date returning a new object

在日期‘秒’上添加数字amount(可为负数),返回日期类型

7

addWeeks(Date date, int amount)

static Date

Adds a number of weeks to a date returning a new object

在日期‘星期’上添加数字amount(可为负数),返回日期类型

8

addYears(Date date, int amount)

static Date

Adds a number of years to a date returning a new object

在日期‘年’上添加数字amount(可为负数),返回日期类型

9

ceiling(Calendar date, int field)

 

static Calendar

Gets a date ceiling, leaving the field specified as the most significant field

返回一个Calendar,效果为得到一个日期类别(年、月、日、时、分、秒)的数字,例如:d为2017年3月21日;则:DateUtils.ceiling(d, Calendar.MONTH)是2017年4月1日0时0分0秒

10

ceiling(Date date, int field)

 

static Date

Gets a date ceiling, leaving the field specified as the most significant field

同上,区别为参数和返回值为Date类型

11

ceiling(Object date, int field)

 

static Date

Gets a date ceiling, leaving the field specified as the most significant field

同上,区别为参数为Object类型。注意该Object对象需要和Date、Calendar对象任一转换。



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值