Android Calendar Format string2calendar(String s, String formatString)

Here you can find the source of string2calendar(String s, String formatString)

Description

stringcalendar

License

Apache License

Declaration

public static Calendar string2calendar(String s, String formatString) 

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 Calendar string2calendar(String s, String formatString) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(formatString);
        Date d = null;//from w w  w.  ja  va 2  s . c o m
        try {
            d = sdf.parse(s);
        } catch (ParseException ignore) {
        }
        calendar.setTime(d);
        // http://stackoverflow.com/questions/5301226/convert-string-to-calendar-object-in-java

        return calendar;

        /*
         NOTE: ?????????????????????????????????????????????
         Date date = null;
         Calendar calendar = Calendar.getInstance();
         try {
         date = DateFormat.getDateInstance().parse(s);
         calendar.setTime(date);
         // http://sauke-11.jugem.jp/?eid=63
         // http://d.hatena.ne.jp/chiheisen/20091123/1258986655
         } catch (ParseException ignore) {
         }
         return calendar;
         */
    }
}

Related

  1. getFormattedTime(Context context, Calendar time)
  2. calendar2string(Calendar calendar, String formatString)
  3. format(Calendar cal, String format, Locale locale)
  4. getCalendarFromDateString(String dateString, String format, Locale locale)
  5. getFormatedDate(Calendar c, String format)
  6. toSimpleDate(Calendar calendar, String format)
  7. getCurrentDateString(String dateFormat)
  8. getAsString(Calendar date)
  9. formatCalendar(Calendar calendar)