List of utility methods to do Gregorian Date Create
boolean | isGregorianDate(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); ... |
boolean | isValid(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; |
Date | getDateObj(int year, int month, int day) get Date Obj Calendar c = new GregorianCalendar(); c.set(year, month - 1, day); return c.getTime(); |
Calendar | getCalendar() get Calendar Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(new Date()); return calendar; |
String | dateInts2String(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(); ... |