I am new to Java8
and looking to convert the String into Date in order ro save it in Redis. I went through https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html and tried to Patterns for Formatting and Parsing as per my requirement.
public class DateDemo {
public static void main(String[] args) {
DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
String date = "10-10-2018 12:10:17";
LocalDateTime parse = LocalDateTime.parse(date, DATE_FORMAT);
System.out.println("PARSE = "+parse);
}
}
Output: PARSE = 2018-10-10T12:10:17