Android Date String Parse parseString(String dateStr, String pattern)

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

Description

parse String

Declaration

public static Calendar parseString(String dateStr, String pattern)
            throws ParseException 

Method Source Code

//package com.java2s;

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   ww  w  .j  a va2  s. c o m
        return calendar;
    }

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

Related

  1. parseDateTime(String dateString)
  2. parseDateWithLeniency(String str, String[] parsePatterns, boolean lenient)
  3. parseLongFormat(String dateString)
  4. parseSearchApiDateTime(String dateString)
  5. parseString(String dateStr)
  6. parseStringToDate(String str)
  7. parseTM(String s, boolean end)
  8. parseDate(String date)
  9. parse(String dateStr)