Java Parse Date Pattern YYYY parseString(String dateStr)

Here you can find the source of parseString(String dateStr)

Description

parse String

License

Apache License

Declaration

public static Calendar parseString(String dateStr) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String DEFAULTFORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Calendar parseString(String dateStr, String pattern) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date date = sdf.parse(dateStr);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);//from   w  w  w  . j  ava2s.c om
        return calendar;
    }

    public static Calendar parseString(String dateStr) throws ParseException {
        return parseString(dateStr, DEFAULTFORMAT);
    }
}

Related

  1. parseSimpleDate(String string, Date defaultDate)
  2. parseSipDateTime(String dateStr)
  3. parseSolrDate(String date)
  4. parseSpaydDate(String date, TimeZone tz)
  5. parseString(String date)
  6. parseString(String strDate)
  7. parseString2Calendar(String date)
  8. parseString2Date(String date)
  9. parseString2Date(String sDate, String format)