List of utility methods to do Date Get
String | getCurrentDateYearMonthDateHourMinuteSecond() get Current Date Year Month Date Hour Minute Second Calendar calendar = Calendar.getInstance(); SimpleDateFormat toDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); return toDateFormat.format(calendar.getTime()); |
Date | createDate(final int month, final int day, final int year) Create a Date object with the specified date. final Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
...
|
String | getDate(int year, int month) get Date String date = null; String a = String.valueOf(year); String b = String.valueOf(month); if (month > 9) { date = a + b; } else { date = a + "0" + b; return date; |
Date | getDateFromString(String dateString) get Date From String if (!TextUtils.isEmpty(dateString)) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); try { return sdf.parse(dateString); } catch (ParseException e) { e.printStackTrace(); return null; |
String | getCurrentlyDate() get Currently Date SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); return dateFormat.format(new Date()); |
Date | getDate(int day, int month, int year) get Date return getCalendar(day, month, year).getTime();
|