Android Utililty Methods Gregorian Date Create

List of utility methods to do Gregorian Date Create

Description

The list of methods to do Gregorian Date Create are organized into topic(s).

Method

booleanisGregorianDate(int year, int month, double day)
Calculates whether the given date is Gregorian, i.e.
Calendar gregorianZero = new GregorianCalendar(
        TimeZone.getTimeZone("GMT"));
gregorianZero.set(Calendar.YEAR, 1582);
gregorianZero.set(Calendar.MONTH, 9); 
gregorianZero.set(Calendar.DAY_OF_MONTH, 15);
Calendar calendar = new GregorianCalendar(
        TimeZone.getTimeZone("GMT"));
calendar.set(Calendar.YEAR, year);
...
booleanisValid(int year, int month, int day)
is Valid
if (month > 0 && month < 13 && day > 0 && day < 32) {
    int mon = month - 1;
    Calendar calendar = new GregorianCalendar(year, mon, day);
    if (calendar.get(Calendar.YEAR) == year
            && calendar.get(Calendar.MONTH) == mon
            && calendar.get(Calendar.DAY_OF_MONTH) == day) {
        return true;
return false;
DategetDateObj(int year, int month, int day)
get Date Obj
Calendar c = new GregorianCalendar();
c.set(year, month - 1, day);
return c.getTime();
CalendargetCalendar()
get Calendar
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(new Date());
return calendar;
StringdateInts2String(int year, int month, int day)
date Ints String
try {
    GregorianCalendar dateGC = new GregorianCalendar(year, month,
            day);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String date = sdf.format(dateGC.getTime());
    return date;
} catch (Exception e) {
    e.printStackTrace();
...