List of utility methods to do Date Time Get
String | getCurDateTime() get Cur Date Time return getCurDateTime(DEFAULTFORMAT);
|
String | getCurDateTime(String pattern) get Cur Date Time return formatCalendar(Calendar.getInstance(), pattern);
|
String | getCurrentDate(String time) get Current Date DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); return dateFormat.format(Long.valueOf(time)); |
String | getCurrentDate(long time) get Current Date DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); return dateFormat.format(time); |
String | getDatetime() get Datetime, "yyyy-MM-dd HH:mm:ss" Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATETIME); return sdf.format(calendar.getTime()); |
boolean | isNight() is Night SimpleDateFormat sdf = new SimpleDateFormat("HH"); int hour = Integer.valueOf(sdf.format(new Date())); return hour > 18 || hour < 6; |
String | getDateDifference(Date thenDate) get Date Difference Calendar now = Calendar.getInstance(); Calendar then = Calendar.getInstance(); now.setTime(new Date()); then.setTime(thenDate); long nowMs = now.getTimeInMillis(); long thenMs = then.getTimeInMillis(); long diff = nowMs - thenMs; long diffMinutes = diff / (60 * 1000); ... |
String | currentTimeLabel() Returns label for current time. return formatter.format(new Date(System.currentTimeMillis())); |
String | currentTimeToString(int format, String delimiter) current Time To String return formatDate(new Date(), format, delimiter); |
String | getDate() get Date Calendar c = Calendar.getInstance(); int theYear = c.get(Calendar.YEAR) - 1900; int theMonth = c.get(Calendar.MONTH); int theDay = c.get(Calendar.DAY_OF_MONTH); return (new Date(theYear, theMonth, theDay)).toString(); |