java.time
In March 2014, Java 8 introduced the modern, java.time date-time API which supplanted the error-prone legacy java.util date-time API. Any new code should use the java.time API*.
Also, shown below is a notice on the Joda-Time Home Page:
Note that from Java SE 8 onwards, users are asked to migrate to java.time (JSR-310) - a core part of the JDK which replaces this
project.
Solution using modern date-time API
Given below is the excerpt from OffsetDateTime#parse documentation:
Obtains an instance of OffsetDateTime from a text string such as
2007-12-03T10:15:30+01:00.
The string must represent a valid date-time and is parsed using
DateTimeFormatter.ISO_OFFSET_DATE_TIME.
Since your text string, 2011-11-19T00:00:00.000-05:00 fully complies with the default format, you do not need to specify any DateTimeFormatter explicitly.
Demo:
import java.time.*;
public class Main {
public static void main(String[] args) {
OffsetDateTime odt = OffsetDateTime.parse("2011-11-19T00:00:00.000-05:00");
System.out.println(odt);
}
}
Output:
2011-11-19T00:00-05:00
Online Demo
Note: If for some reason, you need an instance of java.util.Date, let java.time API do the heavy lifting of parsing the date-time string and convert odt from the above code into a java.util.Date instance using Date date = Date.from(odt.toInstant()).
Learn more about the modern Date-Time API from Trail: Date Time.
* If you are receiving an instance of java.util.Date, convert it tojava.time.Instant, using Date#toInstant and derive other date-time classes of java.time from it as per your requirement.