LocalDate date = LocalDate.parse("2023-06-18");
LocalDateTime dateTime = LocalDateTime.parse("2023-06-18T12:52:55");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2023-06-18 14:15:30 Europe/Berlin", formatter);
String dateInString = "19850709";
LocalDate date = LocalDate.parse(dateInString, DateTimeFormatter.BASIC_ISO_DATE);
String dateInString = "Mon, 15 May 1985";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, d MMM yyyy", Locale.ENGLISH);
LocalDate dateTime = LocalDate.parse(dateInString, formatter);
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
String dateInString = "18-Jun-2015";
Date date = formatter.parse(dateInString);
SimpleDateFormat formatter = new SimpleDateFormat("dd-M-yyyy hh:mm:ss a", Locale.ENGLISH);
formatter.setTimeZone(TimeZone.getTimeZone("America/New_York"));
String dateInString = "23-01-2018 12:15:53 AM";
Date date = formatter.parse(dateInString);
String formattedDateString = formatter.format(date);
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.2</version>
</dependency>
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
String dateInString = "01/08/2022 14:17:59";
DateTime dateTime = DateTime.parse(dateInString, formatter);
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
String dateInString = "01/08/2022 14:17:59";
DateTime dateTime = DateTime.parse(dateInString, formatter);
DateTime dateTimeWithZone = dateTime.withZone(DateTimeZone.forID("America/Los_Angeles"));
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
String dateInString = "07/08-2017";
Date date = DateUtils.parseDate(dateInString, new String[] { "yyyy-MM-dd HH:mm:ss", "dd/MM-yyyy" });