-1

I would like to convert a String object in java to a Datetime. The String has the following format:

ddMMyyyyhhmm

I wonder if there is a short way to do it.

Abimaran Kugathasan
  • 29,154
  • 11
  • 70
  • 102

2 Answers2

4

try to use Simple date formatter, like:

SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyyhhmm");// or any date format you want
Date date = sdf.parse(s);
Salah
  • 8,304
  • 3
  • 24
  • 41
0

Something like this?

 String string = "date string here"

 DateTimeFormatter formatter = DateTimeFormat.forPattern("ddMMyyyyHHmm");
 DateTime dt = formatter.parseDateTime(string);
Henrik
  • 1,717
  • 4
  • 18
  • 45