Following:
public static void main(String[] args) {
String fromDate = "Thu Aug 02 2012 02:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)";
String fromDateConverted = fromDate.replaceAll("\\+(..)(..)", "+$1:$2");
System.out.println("ORG: " + fromDate);
System.out.println("CNV: " + fromDateConverted);
SimpleDateFormat parseFormat = new SimpleDateFormat("EE MMM dd yyyy HH:mm:ss zzzz", Locale.ENGLISH);
Date theDate = parseFormat.parse(fromDateConverted);
SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.0000000");
System.out.println("EDM: " + outFormat.format(theDate));
}
produces:
ORG: Thu Aug 02 2012 02:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
CNV: Thu Aug 02 2012 02:00:00 GMT+02:00 (Mitteleuropäische Sommerzeit)
EDM: 2012-08-02T03:00:00.0000000
Pay attention to the conversion for the time zone. Java SimpleDateFormatexpects colons in offset.
, , XML OData Atom XML . Edm.DataTime .
. ( TZ - GMT + 1, 03:00 02:00 GMT + 2), outFormat, :
outFormat.setTimeZone(TimeZone.getTimeZone("PST"));