android 日历加1,在Android中将月份1添加到日历月的日历问题

使用以下任一方法,这种日期时间工作更容易:

与Java捆绑在一起的java.util.Date和.Calendar类的热门替代品

开源

免费

积极维护(截至2014-02)

灵感来自Joda-Time,但重新设计

示例代码

DateTimeZone timeZone = DateTimeZone.forID( "Europe/Paris" ); // Or, DateTimeZone.UTC

DateTime dateTime = new DateTime( timeZone );

DateTime monthAgo = dateTime.plusMonths( -1 ); // Smartly handles various month lengths, leap year, and so on.

DateTime monthLater = dateTime.plusMonths( 1 );

转储到控制台......

System.out.println( "dateTime: " + dateTime );

System.out.println( "monthAgo: " + monthAgo );

System.out.println( "monthAgo start of day: " + monthAgo.withTimeAtStartOfDay() );

System.out.println( "monthLater: " + monthLater );

跑的时候......

dateTime: 2014-02-24T01:53:22.386+01:00

monthAgo: 2014-01-24T01:53:22.386+01:00

monthAgo start of day: 2014-01-24T00:00:00.000+01:00

monthLater: 2014-03-24T01:53:22.386+01:00

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值