当前位置:网站首页>joda. Time get date summary

joda. Time get date summary

2022-06-25 06:43:00 Flying page

1、 Get the current date and yesterday's date ( Format yyyy-MM-dd)

@Test
 public void testJodaTime(){
    
     LocalDate localDate = new LocalDate();
     System.out.println(localDate.toString());// Get current date  2022-06-23
     LocalDate yesterday = localDate.plusDays(-1);//  Push forward one day , Get yesterday's date 
     System.out.println(yesterday.toString());// 2022-06-22
 }

 Insert picture description here

2、 Get a specific year 、 month 、 Japan

@Test
    public void testJodaTime(){
    
        DateTime dateTime = new DateTime();
        int day = dateTime.getDayOfMonth();
        int month = dateTime.getMonthOfYear();
        int year = dateTime.getYear();
        System.out.println(" It's today "+ day +" Number ");
        System.out.println(" Now it is "+ month +" month ");
        System.out.println(" Now it is "+ year +" year ");
    }

 Insert picture description here

原网站

版权声明
本文为[Flying page]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250424278877.html