Julian day of the year in Java

后端 未结 9 1045
挽巷
挽巷 2020-11-30 12:12

I have seen the \"solution\" at http://www.rgagnon.com/javadetails/java-0506.html, but it doesn\'t work correctly. E.g. yesterday (June 8) should have been 159, but it said

9条回答
  •  时光说笑
    2020-11-30 12:41

    Following @Basil Bourque answer, below is my implementation to get the Julian day of the year using system default Zone ID.

    LocalDate localDate = LocalDate.now(ZoneId.systemDefault());
    int julianDay = localDate.getDayOfYear();
    

提交回复
热议问题