Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static java.util.Date ConvertFromWebService(String strDate) { java.lang.String[] formats = new java.lang.String[] { "yyyy-MM-dd'T'HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm", "yyyy-MM-dd" }; for (java.lang.String frm : formats) { try { SimpleDateFormat format = new SimpleDateFormat(frm, Locale.US); format.setTimeZone(java.util.TimeZone.getTimeZone("UTC")); return format.parse(strDate); } catch (java.lang.Exception ex) { } } return null; } }