Android Gregorian Date Create isValid(int year, int month, int day)

Here you can find the source of isValid(int year, int month, int day)

Description

is Valid

License

Open Source License

Declaration

public static boolean isValid(int year, int month, int day) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    public static boolean isValid(int year, int month, int day) {
        if (month > 0 && month < 13 && day > 0 && day < 32) {
            // month of calendar is 0-based
            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;
            }/*  ww w.j  ava2 s  .  c  o  m*/
        }
        return false;
    }
}

Related

  1. isGregorianDate(int year, int month, double day)
  2. getDateObj(int year, int month, int day)
  3. getCalendar()
  4. dateInts2String(int year, int month, int day)