List of utility methods to do Date Start
Date | getStartTimeOfDay(Date date)Start time of the given date, specific to the second.Date result = null; if (date != null) { Calendar calendar = getCalendar(date); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DATE); calendar.set(year, month, day, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); ... |
Date | getStartTimeOfDay(Date date) Get the start time date-time of the given day (ie. Calendar currentCalendar = new GregorianCalendar(); currentCalendar.setTime(date); currentCalendar.set(HOUR_OF_DAY, 0); currentCalendar.set(MINUTE, 0); currentCalendar.set(SECOND, 0); return currentCalendar.getTime(); |
Date | getStrDateToDate(String dateStr) get Str Date To Date String dateSplit = getDateSplit(); if (dateSplit.equals(".")) dateSplit = "\\."; StringTokenizer filter = new StringTokenizer(dateStr, dateSplit); int year = Integer.parseInt(filter.nextToken()); int mon = Integer.parseInt(filter.nextToken()) - 1; int day = Integer.parseInt(filter.nextToken()); Calendar cal = new GregorianCalendar(year, mon, day); ... |
String | getStringDate() get String Date Calendar calendar = Calendar.getInstance(); StringBuffer sb = new StringBuffer(); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); sb.append(calendar.get(Calendar.YEAR)); if (month < 10) { sb.append(0); sb.append(month); ... |
long | getStringDate(byte[] block, int pos) get String Date int i = pos - 1;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, toInt(block, i, 4));
cal.set(Calendar.MONTH, toInt(block, (i = i + 4), 2) - 1);
cal.set(Calendar.DATE, toInt(block, (i = i + 2), 2));
cal.set(Calendar.HOUR_OF_DAY, toInt(block, (i = i + 2), 2));
cal.set(Calendar.MINUTE, toInt(block, (i = i + 2), 2));
cal.set(Calendar.SECOND, toInt(block, (i = i + 2), 2));
...
|
Calendar | getStringInDate(String dateString) get String In Date String[] split = dateString.split("/"); return new GregorianCalendar(Integer.parseInt(split[2]), Integer.parseInt(split[1]) - 1, Integer.parseInt(split[0])); |