Converting a date string to a DateTime in Java

Converting a date string to a DateTime object using Joda Time library


Include the following imports in the class

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

The following will convert date String to Date Time

DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
DateTime dateTime = formatter.parseDateTime(dateString);

No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days