If I already have a date's month, day, and year as integers, what's the best way to use them to create a LocalDate
object? I found this post String to LocalDate , but it starts with a String
representation of the date.
23
votes
3 Answers
37
votes
18
votes
You can create LocalDate like this, using ints
LocalDate inputDate = LocalDate.of(year,month,dayOfMonth);
and to create LocalDate from String you can use
String date = "04/04/2004";
inputDate = LocalDate.parse(date,
DateTimeFormat.forPattern("dd/MM/yyyy"));
You can use other formats too but you have to change String in forPattern(...)