How to know the number of the current day in the current years using Java?
问题 I have to calculate in Java what is the number of the current day in the year. For example if today is the 1 of January the resut should be 1 . If it is the 5 of February the result should be 36 How can I automatically do it in Java? Exist some class (such as Calendar ) that natively supports this feature? 回答1: You can use java.util.Calendar class. Be careful that month is zero based. So in your case for the first of January it should be: Calendar calendar = new GregorianCalendar(2015, 0, 1);