Java Parse Date Pattern YYYY parseString2Date(String date)

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

Description

parse String Date

License

Open Source License

Declaration

public static Date parseString2Date(String date) throws ParseException 

Method Source Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String PATTERN = "yyyy-MM-dd";

    public static Date parseString2Date(String date, String pattern) throws ParseException {
        return getSimpleDateFormatInstance(pattern).parse(date);
    }/* w ww .  j  a va  2  s .  c  o  m*/

    public static Date parseString2Date(String date) throws ParseException {
        return parseString2Date(date, null);
    }

    private static SimpleDateFormat getSimpleDateFormatInstance(String pattern) {
        return new SimpleDateFormat(pattern == null ? PATTERN : pattern);
    }
}

Related

  1. parseSpaydDate(String date, TimeZone tz)
  2. parseString(String date)
  3. parseString(String dateStr)
  4. parseString(String strDate)
  5. parseString2Calendar(String date)
  6. parseString2Date(String sDate, String format)
  7. parseString2Long(String strDate)
  8. parseStringAsDate(String pattern, String value)
  9. parseStringDate(String dateAsString)