List of usage examples for java.util Calendar MILLISECOND
int MILLISECOND
To view the source code for java.util Calendar MILLISECOND.
Click Source Link
get
and set
indicating the millisecond within the second. From source file:Main.java
/** * Parses a date/time string from within an XMLTV stream. Only the local * time part of the value is parsed. Timezone specifications are ignored. * /* w w w .j ava 2 s .co m*/ * @param str the string * @param convertTimezone true to convert date/time values to local time * @return the date/time value as a Calendar object */ public static Calendar parseDateTime(String str, boolean convertTimezone) { // Format looks like: 20111209060000 +1100 if (str == null) return null; int year = parseField(str, 0, 4); int month = parseField(str, 4, 2); int day = parseField(str, 6, 2); int hour = parseField(str, 8, 2); int minute = parseField(str, 10, 2); int second = parseField(str, 12, 2); if (convertTimezone) { if (cachedTimeZone == null) { cachedTimeZone = TimeZone.getDefault(); cachedOffset = cachedTimeZone.getOffset(System.currentTimeMillis()); } int tz = parseTZField(str, 14); if (tz != cachedOffset) { Calendar calendar = new GregorianCalendar(year, month - 1, day, hour, minute, second); calendar.add(Calendar.MILLISECOND, cachedOffset - tz); return calendar; } } return new GregorianCalendar(year, month - 1, day, hour, minute, second); }
From source file:com.westlinkin.android_feedback_helper.utils.MailUntils.java
private static String getFeedbackNumber() { Calendar calendar = Calendar.getInstance(); return "" + calendar.get(Calendar.YEAR) + Utils.formatCalendarIntValue((calendar.get(Calendar.MONTH) + 1), 2) + Utils.formatCalendarIntValue(calendar.get(Calendar.DAY_OF_MONTH), 2) + "-" + Utils.formatCalendarIntValue(calendar.get(Calendar.HOUR_OF_DAY), 2) + Utils.formatCalendarIntValue(calendar.get(Calendar.MINUTE), 2) + Utils.formatCalendarIntValue(calendar.get(Calendar.SECOND), 2) + "-" + Utils.formatCalendarIntValue(calendar.get(Calendar.MILLISECOND), 3); }
From source file:com.intuit.wasabi.assignmentobjects.DateHour.java
public void setDateHour(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww . ja v a 2s .c o m*/ cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); this.day_hour = cal.getTime(); }
From source file:com.wanikani.wklib.UserInformation.java
private static Calendar getNormalizedCalendar(Date date) { Calendar ans;//from w ww . jav a2 s.com ans = Calendar.getInstance(); ans.setTime(date); ans.set(Calendar.HOUR, 1); ans.set(Calendar.MINUTE, 2); ans.set(Calendar.SECOND, 3); ans.set(Calendar.MILLISECOND, 4); return ans; }
From source file:DateUtils.java
public static String getTime() { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); int hours = cal.get(Calendar.HOUR_OF_DAY); // use 24 hour clock int minutes = cal.get(Calendar.MINUTE); int seconds = cal.get(Calendar.SECOND); int milli = cal.get(Calendar.MILLISECOND); return formatTime(hours, minutes, seconds, milli); }
From source file:com.adobe.acs.commons.http.headers.impl.DailyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPast() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());/*from ww w. j a va2s .c o m*/ expected.add(Calendar.DAY_OF_MONTH, 1); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); }
From source file:com.qpark.eip.core.spring.statistics.impl.SysUserStatisticsChannelInvocationListener.java
/** * Get a {@link Date}, where hours, minutes, seconds and milliseconds are * set to 0.//w w w . j ava2 s . co m * * @return the {@link Date} and the corresponding log string. */ public static Calendar getRequestDate() { Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc; }
From source file:com.jennifer.ui.util.TimeUtil.java
public static Date add(Date d, String type, int interval) { Calendar c = Calendar.getInstance(); c.setTime(d);//from ww w. ja v a 2s . c o m if (Time.YEARS.equals(type)) { c.add(Calendar.YEAR, interval); } else if (Time.MONTHS.equals(type)) { c.add(Calendar.MONTH, interval); } else if (Time.DAYS.equals(type)) { c.add(Calendar.DATE, interval); } else if (Time.HOURS.equals(type)) { c.add(Calendar.HOUR_OF_DAY, interval); } else if (Time.MINUTES.equals(type)) { c.add(Calendar.MINUTE, interval); } else if (Time.SECONDS.equals(type)) { c.add(Calendar.SECOND, interval); } else if (Time.MILLISECONDS.equals(type)) { c.add(Calendar.MILLISECOND, interval); } else if (Time.WEEKS.equals(type)) { c.add(Calendar.DATE, interval * 7); } return c.getTime(); }
From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsEraser.java
/** * Each day at 0:00 remove old out dated entries. *///from w w w .ja va 2s. co m @Scheduled(cron = "0 0 0 * * *") public void erase() { Calendar gc = new GregorianCalendar(); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); gc.add(Calendar.WEEK_OF_YEAR, -1 * Math.abs(this.numberOfWeeksToKeepLogs)); this.dao.eraseSystemUserLog(gc.getTime()); this.dao.eraseApplicationUserLog(gc.getTime()); this.dao.eraseFlowLogMessage(gc.getTime()); }
From source file:com.worldline.easycukes.rest.utils.DateHelper.java
/** * Used to convert date value in json date format * * @param value// w ww. ja v a2 s.c om * @return */ public static String convertDateToJsonFormat(@NonNull final Date value) { log.info("setting the date value " + value + " to format json"); final Calendar calendar = Calendar.getInstance(); calendar.setTime(value); return calendar.get(Calendar.YEAR) + "-" + formatTo2Digit(calendar.get(Calendar.MONTH) + 1) + "-" + formatTo2Digit(calendar.get(Calendar.DAY_OF_MONTH)) + "T" + formatTo2Digit(calendar.get(Calendar.HOUR_OF_DAY)) + ":" + formatTo2Digit(calendar.get(Calendar.MINUTE)) + ":" + formatTo2Digit(calendar.get(Calendar.SECOND)) + ":" + calendar.get(Calendar.MILLISECOND) + "Z"; }