Java tutorial
import java.util.Calendar; import java.util.Date; public class Util { public static String isoDateTimeToDate(String isoDate) { StringBuffer sb = new StringBuffer(isoDate); int maxlen; if (isoDate.length() >= 10) { //2007-01-01 -> 20070101 //remove hyphens between year, month, and day sb.deleteCharAt(4); sb.deleteCharAt(6); maxlen = 8; //20070101T17:30:12 -> 20070101T173012 if (isoDate.length() >= 19) { maxlen = 15; //remove colons between hours, minutes, and seconds sb.deleteCharAt(11); sb.deleteCharAt(13); if (isoDate.indexOf("Z") >= 0) { sb.insert(15, 'Z'); ++maxlen; } } if (sb.length() > maxlen) sb.setLength(maxlen); } return sb.toString(); } }