Here you can find the source of parse(String date)
Parameter | Description |
---|---|
date | the date |
Parameter | Description |
---|---|
ParseException | the parse exception |
public static Date parse(String date) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** The Constant UTC_TIME_ZONE. */ public final static TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC"); /** The Constant DATE_TIME_PATTERN. */ public final static String DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; /**/*from w w w .ja va2s .co m*/ * Parses the date. * * @param date the date * @return the parsed date * @throws ParseException the parse exception */ public static Date parse(String date) throws ParseException { DateFormat df = getThreadLocalDateFormat(); return df.parse(date); } /** * Gets the thread local date format. * * @return the thread local date format */ private static DateFormat getThreadLocalDateFormat() { DateFormat result = new SimpleDateFormat(DATE_TIME_PATTERN); result.setTimeZone(UTC_TIME_ZONE); return result; } }