Java Parse Date Pattern YYYY parse(String date)

Here you can find the source of parse(String date)

Description

Parses the date.

License

Open Source License

Parameter

Parameter Description
date the date

Exception

Parameter Description
ParseException the parse exception

Return

the parsed date

Declaration

public static Date parse(String date) throws ParseException 

Method Source Code


//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;
    }
}

Related

  1. parse(String calendarString)
  2. parse(String d)
  3. parse(String date)
  4. parse(String date)
  5. parse(String date)
  6. parse(String date)
  7. parse(String date)
  8. parse(String date)
  9. parse(String date)