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:

 My Attempt to learn AI  GPT Generative Pretrained Transformer Created by Google in 2017 with the publication of the paper "Attention ...

Popular in last 30 days