java LocalDate 与 LocalTime类
来源:互联网 发布:四知文言文翻译注解 编辑:程序博客网 时间:2024/06/17 23:57
http://blog.csdn.net/chenxun_2010/article/details/72539981
LocalDate today=LocalDate.now(); System.out.println(today); int year=today.getYear(); int month=today.getMonthValue(); int day=today.getDayOfMonth(); System.out.println(year);System.out.println(month);System.out.println(day); LocalDate well= LocalDate.of(1999,12,11); System.out.println(well+"================");
* 这看起来没有多大意义,因为这正是构造对象时使用的那些值。不过,有时可能某个时间是计算得到的,你希望调用这些方法来得到更多信息。例如,plusDays方法会得到一个新的LocalDate,如果把应用这个方法的对象称为当前对象,这个新日期对象则是局当前对象制定天数的一个新日期: * LocalDate aThousandDaysLater =today.plusDays(1000); year=aThousandDaysLater.getYear(); month=aThousandDaysLater.getMonthValue(); day=aThousandDaysLater.getDayOfMonth(); System.out.println(year);System.out.println(month);System.out.println(day); * LocalDate类封装了实例域来维护所设置的日期。如果不查看源代码,就不可能知道类内部的日期表示。当然,封装的意义就在于此。
LocalDate aThousandDaysLater =today.plusDays(1000); year=aThousandDaysLater.getYear(); month=aThousandDaysLater.getMonthValue(); day=aThousandDaysLater.getDayOfMonth(); System.out.println(year);System.out.println(month);System.out.println(day);
package 第3章;import java.util.*;import java.time.*;public class 第3章a{ public static void main(String[] args) { LocalDate today=LocalDate.now(); int year=today.getYear(); int month=today.getMonthValue(); int day=today.getDayOfMonth(); System.out.println(year);System.out.println(month);System.out.println(day); System.out.println("以上是获得当前整个时间,以及获取year,month,day"+"以下是构造特定对象:"); LocalDate well=LocalDate.of(2001,1,2); System.out.println(well); LocalDate good=LocalDate.of(2001,12,2); System.out.println(good); year=good.getYear(); month=good.getMonthValue(); day=good.getDayOfMonth(); System.out.println(year); System.out.println(month); System.out.println(day); LocalDate hello=good.plusDays(1000); System.out.println(hello); } }
run:2017822以上是获得当前整个时间,以及获取year,month,day以下是构造特定对象:2001-01-022001-12-0220011222004-08-28成功构建 (总时间: 0 秒)
阅读全文
0 0
- java LocalDate 与 LocalTime类
- Java 时间类-Calendar、Date、LocalDate/LocalTime
- Java 时间类-Calendar、Date、LocalDate/LocalTime
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Java 8 中 Date与LocalDateTime、LocalDate、LocalTime互转
- Date与LocalDateTime、LocalDate、LocalTime互转
- Date与LocalDate,LocalDateTime,LocalTime的转换
- Java 8---LocalDate,LocalTime处理日期时间
- Java 8---LocalDate,LocalTime处理日期时间
- Date、LocalTime、LocalDate、LocalDate-时间操作工具类
- LocalDate、LocalTime、LocalDateTime
- java的LocalDate类使用
- java学习记录(3)-- Java8日期API LocalDate & LocalTime &Junit
- Hadoop集群压力测试
- ubuntu下Android Studio 提交代码至Github
- 页面高度不够时,底部固定在下面
- 二元多项式
- 嵌入式系统概论-1.4
- java LocalDate 与 LocalTime类
- Result Maps collection does not contain value for 问题
- Oracle语法限制,in内元素数量必须不大于1000
- 机器学习--- 一元线性回归数学推导以及Python实现
- φ(1)=1 [Sdoi2008]沙拉公主的困惑
- 一个简单的php站点配置
- 网购秒杀系统架构案例分析
- mybatis在xml文件中处理大于号小于号的方法
- 深入理解Java垃圾回收机制