try this
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").parse(s);
or this
javax.xml.bind.DatatypeConverter.parseDateTime("2014-04-23T18:30:00.000Z");
the last version is supposed to be faster (no need to parse pattern) and thread-safe
Pergunta
2014-04-23T18:30:00.000Z
need to convert in this format yyyy-MM-dd'T'hh:mm:sszzz
in java
I am using this
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.zzzZ");
Date newfromDate = new Date();
try {
//Convert into date
newfromDate = (Date)formatter.parse(fromDate);
// get required Format of date in string format
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:sszzz");
} catch (ParseException e) {
e.printStackTrace();
}
but this is not working
error :- java.text.ParseException: Unparseable date: "2014-03-31T18:30:00.000Z"
Solução
try this
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").parse(s);
or this
javax.xml.bind.DatatypeConverter.parseDateTime("2014-04-23T18:30:00.000Z");
the last version is supposed to be faster (no need to parse pattern) and thread-safe