-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.

2
  • 1
    Heard of SimpleDateFormat ? Commented Mar 5, 2014 at 7:36
  • You mean the jodatime DateTime? Commented Mar 5, 2014 at 7:37

2 Answers 2

4

try to use Simple date formatter, like:

SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyyhhmm");// or any date format you want
Date date = sdf.parse(s);
Sign up to request clarification or add additional context in comments.

Comments

0

Something like this?

 String string = "date string here"

 DateTimeFormatter formatter = DateTimeFormat.forPattern("ddMMyyyyHHmm");
 DateTime dt = formatter.parseDateTime(string);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.