Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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.
SimpleDateFormat
DateTime
try to use Simple date formatter, like:
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyyhhmm");// or any date format you want Date date = sdf.parse(s);
Add a comment
Something like this?
String string = "date string here" DateTimeFormatter formatter = DateTimeFormat.forPattern("ddMMyyyyHHmm"); DateTime dt = formatter.parseDateTime(string);
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
SimpleDateFormat?DateTime?