Android Calendar Format getCalendarFromDateString(String dateString, String format, Locale locale)

Here you can find the source of getCalendarFromDateString(String dateString, String format, Locale locale)

Description

get Calendar From Date String

Declaration

public static Calendar getCalendarFromDateString(String dateString,
            String format, Locale locale) 

Method Source Code

import android.annotation.SuppressLint;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

public class Main{
    public static Calendar getCalendarFromDateString(String dateString,
            String format, Locale locale) {
        SimpleDateFormat formatter = new SimpleDateFormat(format, locale);
        Calendar cal = Calendar.getInstance();
        try {//  w w  w  .  j  av  a  2s.c o m
            cal.setTime(formatter.parse(dateString));
        } catch (ParseException e) {
            DebugLog.e("ParseException");
            return null;
        }
        return cal;
    }
}

Related

  1. getUniversalDateStamp(Calendar cal)
  2. getFormattedTime(Context context, Calendar time)
  3. getFormattedTime(Context context, Calendar time)
  4. calendar2string(Calendar calendar, String formatString)
  5. format(Calendar cal, String format, Locale locale)
  6. getFormatedDate(Calendar c, String format)
  7. string2calendar(String s, String formatString)
  8. toSimpleDate(Calendar calendar, String format)
  9. getCurrentDateString(String dateFormat)