List of utility methods to do Date Get
Date | getDate(String sDate, String dateFormat) get Date SimpleDateFormat fmt = new SimpleDateFormat(dateFormat); ParsePosition pos = new ParsePosition(0); return fmt.parse(sDate, pos); |
Date | getDate(int year, int month, int date, int hourOfDay, int minute, int second) get Date Calendar cal = new GregorianCalendar(); cal.set(year, month, date, hourOfDay, minute, second); return cal.getTime(); |
Date | getDateFromString(String dateStr, String pattern) get Date From String SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date resDate = null; try { resDate = sdf.parse(dateStr); } catch (Exception e) { e.printStackTrace(); return resDate; ... |
Date | getDateObj() get Date Obj Calendar c = new GregorianCalendar(); return c.getTime(); |
Date | getDateObj(String argsDate, String split) get Date Obj String[] temp = argsDate.split(split); int year = Integer.valueOf(temp[0]); int month = Integer.valueOf(temp[1]); int day = Integer.valueOf(temp[2]); return getDateObj(year, month, day); |
Date | getDateObj(int year, int month, int day) get Date Obj Calendar c = new GregorianCalendar(); c.set(year, month - 1, day); return c.getTime(); |
String | getDateOffset(String date, int offset) get Date Offset Date tempDate = null; if (date.indexOf("/") > 0) tempDate = getDateObj(date, "[/]"); if (date.indexOf("-") > 0) tempDate = getDateObj(date, "[-]"); tempDate = getDateAdd(tempDate, offset); return getFormatDateTime(tempDate, "yyyy/MM/dd"); |
String | getDateTomorrow(String date) get Date Tomorrow Date tempDate = null; if (date.indexOf("/") > 0) tempDate = getDateObj(date, "[/]"); if (date.indexOf("-") > 0) tempDate = getDateObj(date, "[-]"); tempDate = getDateAdd(tempDate, 1); return getFormatDateTime(tempDate, "yyyy/MM/dd"); |
int | getDayOfWeek(Date date) get Day Of Week Calendar cal = new GregorianCalendar(); cal.setTime(date); return cal.get(Calendar.DAY_OF_WEEK); |
int | getDayOfWeek(String date) get Day Of Week String[] temp = null; if (date.indexOf("/") > 0) { temp = date.split("/"); if (date.indexOf("-") > 0) { temp = date.split("-"); return getDayOfWeek(temp[0], temp[1], temp[2]); ... |