-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
  • 31,165
  • 11
  • 75
  • 105

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,567
  • 3
  • 26
  • 43
0

Something like this?

 String string = "date string here"

 DateTimeFormatter formatter = DateTimeFormat.forPattern("ddMMyyyyHHmm");
 DateTime dt = formatter.parseDateTime(string);
Henrik
  • 1,797
  • 4
  • 22
  • 46