List of utility methods to do Date Now
String | getCurrentUTCString() Get current date in yyyy-dddThh:mm:ss.sss format (GMT) NumberFormat i3 = NumberFormat.getInstance(); NumberFormat i2 = NumberFormat.getInstance(); i3.setMinimumIntegerDigits(3); i2.setMinimumIntegerDigits(2); Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); String date = cal.get(Calendar.YEAR) + "-" + i3.format(cal.get(Calendar.DAY_OF_YEAR)) + "T" + i2.format(cal.get(Calendar.HOUR_OF_DAY)) + ":" + i2.format(cal.get(Calendar.MINUTE)) + ":" + i2.format(cal.get(Calendar.SECOND)) + "." + i3.format(cal.get(Calendar.MILLISECOND)); ... |
Date | getCurrentUTCTime() get Current UTC Time try { return stringDateToDate(getCurrentUTCTimeAsString()); } catch (ParseException e) { e.printStackTrace(); return null; |
String | getCurrentUTCTimeAsString() get Current UTC Time As String final SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); final String utcTime = sdf.format(new Date()); return utcTime; |
String | getCurrentWeekDay(Date date, int day) get Current Week Day Calendar calendar = getCalendarFromDate(date); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(DAYS_OF_A_WEEK); int week = calendar.get(Calendar.WEEK_OF_YEAR); int year = calendar.get(Calendar.YEAR); return formatDate(getDateOfYearWeek(year, week, day)); |
List | getCurrentWeekDays() get Current Week Days List<String> currentweek = new ArrayList<String>(); for (int kindex = 1; kindex <= 7; kindex++) { Calendar c = Calendar.getInstance(); int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; if (day_of_week == 0) day_of_week = 7; c.add(Calendar.DATE, -day_of_week + kindex); String currentday = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); ... |
String | getCurrentWeekFirst() get Current Week First StringBuffer str = new StringBuffer(); java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd"); Calendar c = new GregorianCalendar(); c.setFirstDayOfWeek(Calendar.MONDAY); c.setTime(new Date()); c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); str.append(df.format(c.getTime())); str.append(" 00:00:00"); ... |
String | getCurrentYear() get Current Year if (sCurrentYear == null) { sCurrentYear = new SimpleDateFormat("yyyy").format(Calendar.getInstance().getTime()); return sCurrentYear; |
Date | getCurrentYearBegDate(Date date) get Current Year Beg Date try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String strDate = format.format(date); String[] split = strDate.split("-"); String year = split[0]; String beginDate = year + "-" + "01" + "-" + "01"; Date parse = format.parse(beginDate); return parse; ... |
String | getCurrentYMDDate() get Current YMD Date Calendar cal = Calendar.getInstance(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); CurrentTime = formatter.format(cal.getTime()); return CurrentTime; |
Date | getCurrentZeroTime() get Current Zero Time Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
|