Android Date String Parse parseString(String dateStr)

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

Description

parse String

Declaration

public static Calendar parseString(String dateStr)
            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);//  ww w.  j a  v a2s .co  m
        return calendar;
    }

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

Related

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