Not Joda-Time
Some other Answers are incorrect in suggesting the Joda-Time library. This source code is clearly using the java.time classes built into Java 8 and later.
java.time
The java.time framework is the successor to Joda-Time, defined by JSR 310, and led by the same man as who created Joda-Time, Stephen Colbourne.
Back-ports
To answer the Question, if you are using Java 6 or 7, use the ThreeTen-Backport project. Much of the java.time functionality was back-ported there.
Currently the Maven dependency is:
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>1.3.2</version>
</dependency>
That back-port was further adapted for Android in the ThreeTenABP project. See How to use ThreeTenABP in an Android project
OffsetDateTime
That example code can be simplified. The input data in standard ISO 8601 format can be directly parsed by the OffsetDateTime
class. So need to define a formatting pattern.
OffsetDateTime odt = OffsetDateTime.parse( "2015-01-12T05:00:00.000+0000" ) ;
java.util.Date utilDate = java.util.Date.from( odt.toInstant() ) ;
Or in one line if you insist.
java.util.Date utilDate = java.util.Date.from( OffsetDateTime.parse( "2015-01-12T05:00:00.000+0000" ).toInstant() );
Of course, catch DateTimeParseException
for invalid inputs.