JDK8后的日期时间API
生活随笔
收集整理的這篇文章主要介紹了
JDK8后的日期时间API
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
@Testpublic void test() { // now() 獲取當前的時間,日期LocalDate ld = LocalDate.now();LocalTime lt = LocalTime.now();LocalDateTime ldt = LocalDateTime.now();System.out.println(ld);System.out.println(lt);System.out.println(ldt);// of():指定年月日 時分秒 沒有偏移量LocalDateTime ldt1 = LocalDateTime.of(2021,9,22,17,00,00);System.out.println(ldt1);// getXxx() System.out.println(ldt.getDayOfYear());System.out.println(ldt.getDayOfWeek());System.out.println(ldt.getDayOfMonth());System.out.println(ldt.getMonth());System.out.println("mouthValue:"+ldt.getMonthValue());System.out.println(ldt.getMinute());// withXXX() :可以體現不可變性LocalDate ld1 = ld.withDayOfMonth(26);System.out.println(ld);System.out.println(ld1);}?
?
?
總結
以上是生活随笔為你收集整理的JDK8后的日期时间API的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle 052 题库变了,orac
- 下一篇: java笔试涉及编程题