fork download
  1. import java.time.LocalDate;
  2. import java.time.format.DateTimeFormatter;
  3. import java.util.Locale;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. int dpYear = 2010, dpMonth = 1, dpDayOfMonth = 15;
  8.  
  9. // In DatePicker, the month is indexed starting at 0. Check
  10. // https://stackoverflow.com/a/4467894/10819573 to learn more.
  11. dpMonth++;
  12.  
  13. LocalDate date = LocalDate.of(dpYear, dpMonth, dpDayOfMonth);
  14. System.out.println(date);
  15.  
  16. // Formatted output
  17. DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EEE MMMM dd uuuu", Locale.ENGLISH);
  18. String formatted = dtf.format(date);
  19. System.out.println(formatted);
  20. }
  21. }
Success #stdin #stdout 0.15s 52332KB
stdin
Standard input is empty
stdout
2010-02-15
Mon February 15 2010