How to specify the format string to convert the date alone from string. In my case, only the date part is relevant
Constructing it as DateTime
fails:
In my case, incoming string may be in one of two formats. So I first try to parse string with more specific format:
String s = "2016-02-12";
LocalDateTime ldt;
try {
ldt = LocalDateTime.parse(s, DateTimeFormat.forPattern("YYYY-MM-dd HH:mm"));
}
catch (IllegalArgumentException e) {
ldt = LocalDateTime.parse(s, DateTimeFormat.forPattern("YYYY-MM-dd"));
}