Here you can find the source of getDateFromISOString(String iso)
Parameter | Description |
---|---|
iso | - |
@SuppressWarnings("nls") public static Date getDateFromISOString(String iso)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /**/* www . ja v a 2 s. c o m*/ * */ public static final String ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; /** * @param iso - * @return - */ @SuppressWarnings("nls") public static Date getDateFromISOString(String iso) { SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_FORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); sdf.setLenient(false); try { if (iso == null) return null; return sdf.parse(iso); } catch (ParseException e) { throw new RuntimeException(e); } } }