How do I go from dddd (1-365) and find the mm/dd of that year. I can find the month, but struggle with finding the day of that month.
Asked
Active
Viewed 44 times
0
-
3Please edit your question and show us the code you’ve written so far. I will be particularly interested in whether you’re using the [LocalDate](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/time/LocalDate.html) class. – VGR Apr 17 '19 at 02:57
-
You need to know the year, or at least know whether it’s leap year to get conversions after February (or precisely after day 59 of the year) correct. – Ole V.V. Apr 17 '19 at 06:03
1 Answers
1
Use LocalDate.ofYearDay(int year, int dayOfYear)
:
import java.time.LocalDate;
public class Test {
public static void main(String[] args) {
LocalDate date = LocalDate.ofYearDay(2019, 107);
System.out.println(date.getMonth()); // "APRIL"
System.out.println(date.getDayOfMonth()); // "17"
}
}

Robby Cornelissen
- 91,784
- 22
- 134
- 156