Here you can find the source of parseString(String date)
Parameter | Description |
---|---|
date | The String to parse to a date. |
public static Date parseString(String date)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**/* w w w . ja v a2 s . co m*/ * The storage format for parsing dates. */ public static final String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; /** * Parses a Date to a string using {@link #DATE_STORAGE_FORMAT}. * * <p> * The default storage format is config-friendly, so it may be used in YamlConfig.</p> * * <p> * Parsing <i>never</i> returns null.</p> * * @param date The String to parse to a date. * @return The parsed Date. * @see #parseDate(Date) */ public static Date parseString(String date) { if (date == null || date.isEmpty() || date.trim().equalsIgnoreCase("never")) { return null; } try { return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).parse(date); } catch (ParseException ex) { return new Date(0L); } } }