Here you can find the source of parse(String s)
Parameter | Description |
---|---|
s | the string representation |
Parameter | Description |
---|---|
ParseException | on format error |
public static Date parse(String s) throws ParseException
//package com.java2s; /*//from w ww . j a v a2 s . co m * Copyright 2008-2014, David Karnok * The file is part of the Open Imperium Galactica project. * * The code should be distributed under the LGPL license. * See http://www.gnu.org/licenses/lgpl.html for details. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { /** The date formatter. */ public static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() { @Override protected SimpleDateFormat initialValue() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); sdf.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("GMT"))); return sdf; } }; /** * Parses a date from string. * @param s the string representation * @return the date * @throws ParseException on format error */ public static Date parse(String s) throws ParseException { return DATE_FORMAT.get().parse(s); } }