List of utility methods to do Calendar Time
void | resetTime(GregorianCalendar cal) Sets the time in the given cal to 00:00:00.000 cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); |
long | roundTime(double dt, Calendar tmp) round Time long t = toLongTime(dt); tmp.setTimeInMillis(t); int sec = tmp.get(Calendar.SECOND); return (sec > 30) ? t + (60 - sec) : t - sec; |
boolean | sameTime(Calendar one, Calendar two) Returns true if the two given calendars are dated on the same time. return one.getTimeInMillis() == two.getTimeInMillis();
|
void | setDateTimeByString(Calendar theDateTime, String str) set the calendar value of theDateTime according to a string like "2008-08-08T08:08:08" str = str.trim(); String year, month, day; int i1, i2, iT; i1 = str.indexOf("-"); i2 = str.indexOf("-", i1 + 1); iT = str.indexOf('T'); year = str.substring(0, i1); month = str.substring(i1 + 1, i2); ... |
void | setTime(Calendar cal, int h, int m, int s, int ms) set Time cal.set(Calendar.HOUR_OF_DAY, h); cal.set(Calendar.MINUTE, m); cal.set(Calendar.SECOND, s); cal.set(Calendar.MILLISECOND, ms); |
void | setTime(Calendar cal, String time) set Time int hour = 0; int minute = 0; int idx = time.indexOf(':'); if (idx < 0) { hour = Integer.parseInt(time); } else { hour = Integer.parseInt(time.substring(0, idx)); time = time.substring(idx + 1); ... |
Calendar | setTime(final Calendar calendat, final String[] test) set Time if (test.length == 3) { calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim())); calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim())); calendat.set(Calendar.SECOND, Integer.parseInt(test[2].trim())); if (test.length == 2) { calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim())); calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim())); ... |
void | setTimeFrom(Calendar c) set Time From c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); |
void | setTimeTo0(final Calendar calendar) set Time To calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); |
void | setTimeToMidnight(GregorianCalendar c) Sets the time fields (24-hour, minute, second, millisecond) of the specified GregorianCalendar instance to 0 so it subsequently represents midnight of the same day as before. c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); |