Julian day of the year in Java

后端 未结 9 1040
挽巷
挽巷 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:42

    import java.util.Calendar;
    // ...
    final int julianDay = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
    

    Note that this doesn't take into account the "starts at noon" deal claimed by that weird site you referenced. That could be fixed by just checking the time of course.

提交回复
热议问题