Refine search
/** * Gets the last modification time of this {@code ZipEntry}. * * @return the last modification time as the number of milliseconds since * Jan. 1, 1970. */ public long getTime() { if (time != -1) { GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.MILLISECOND, 0); cal.set(1980 + ((modDate >> 9) & 0x7f), ((modDate >> 5) & 0xf) - 1, modDate & 0x1f, (time >> 11) & 0x1f, (time >> 5) & 0x3f, (time & 0x1f) << 1); return cal.getTime().getTime(); } return -1; }
/** * Gets the last modification time of this {@code android.ZipEntry}. * * @return the last modification time as the number of milliseconds since Jan. 1, 1970. */ public long getTime() { if (time != -1) { GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.MILLISECOND, 0); cal.set(1980 + ((modDate >> 9) & 0x7f), ((modDate >> 5) & 0xf) - 1, modDate & 0x1f, (time >> 11) & 0x1f, (time >> 5) & 0x3f, (time & 0x1f) << 1); return cal.getTime().getTime(); } return -1; }
@Override public Object getDecodedObject(BerInputStream in) throws IOException { GregorianCalendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT")); c.set(Calendar.YEAR, in.times[0]); c.set(Calendar.MONTH, in.times[1]-1); c.set(Calendar.DAY_OF_MONTH, in.times[2]); c.set(Calendar.HOUR_OF_DAY, in.times[3]); c.set(Calendar.MINUTE, in.times[4]); c.set(Calendar.SECOND, in.times[5]); c.set(Calendar.MILLISECOND, in.times[6]); return c.getTime(); } }
protected Date addSingleUnitQuantity(Date startDate, String singleUnitQuantity) { int spaceIndex = singleUnitQuantity.indexOf(" "); if (spaceIndex == -1 || singleUnitQuantity.length() < spaceIndex + 1) { throw new ActivitiIllegalArgumentException("invalid duedate format: " + singleUnitQuantity); } String quantityText = singleUnitQuantity.substring(0, spaceIndex); Integer quantity = new Integer(quantityText); String unitText = singleUnitQuantity.substring(spaceIndex + 1).trim().toLowerCase(); int unit = units.get(unitText); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(startDate); calendar.add(unit, quantity); return calendar.getTime(); } }
public static Date getNextDateAtHour(int hour) { final GregorianCalendar now = new GregorianCalendar(); final GregorianCalendar nextDate = new GregorianCalendar(); // not truncating minutes to distribute load more evenly when multiple instances are started nextDate.set(Calendar.HOUR_OF_DAY, hour); if (nextDate.before(now)) { nextDate.add(Calendar.DAY_OF_YEAR, 1); } return nextDate.getTime(); }
@RequestMapping(method = RequestMethod.GET) public void handle(@CookieValue("date") Date date, Writer writer) throws IOException { assertEquals("Invalid path variable value", new GregorianCalendar(2008, 10, 18).getTime(), date); writer.write("test-" + new SimpleDateFormat("yyyy").format(date)); } }
@RequestMapping("/hotels/{hotel}/dates/{date}") public void handle(@PathVariable("hotel") String hotel, @PathVariable Date date, Writer writer) throws IOException { assertEquals("Invalid path variable value", "42", hotel); assertEquals("Invalid path variable value", new GregorianCalendar(2008, 10, 18).getTime(), date); writer.write("test-" + hotel); } }
@BeforeClass public static void classSetup() { final GregorianCalendar cal = new GregorianCalendar(2000, 6, 5, 4, 3, 2); cal.set(Calendar.MILLISECOND, 1); BASE_DATE = cal.getTime(); }
@Override public void updateProcessInstanceLockTime(String processInstanceId) { Date expirationTime = getClock().getCurrentTime(); int lockMillis = getAsyncExecutor().getAsyncJobLockTimeInMillis(); GregorianCalendar lockCal = new GregorianCalendar(); lockCal.setTime(expirationTime); lockCal.add(Calendar.MILLISECOND, lockMillis); Date lockDate = lockCal.getTime(); executionDataManager.updateProcessInstanceLockTime(processInstanceId, lockDate, expirationTime); }
protected void lockJob(CommandContext commandContext, JobEntity job, int lockTimeInMillis) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, lockTimeInMillis); job.setLockOwner(asyncExecutor.getLockOwner()); job.setLockExpirationTime(gregorianCalendar.getTime()); } }
protected void lockJob(CommandContext commandContext, TimerJobEntity job, int lockTimeInMillis) { // This will trigger an optimistic locking exception when two concurrent executors // try to lock, as the revision will not match. GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); gregorianCalendar.add(Calendar.MILLISECOND, lockTimeInMillis); job.setLockOwner(asyncExecutor.getLockOwner()); job.setLockExpirationTime(gregorianCalendar.getTime()); } }
@Test public void testIsSameDay_Date() { Date datea = new GregorianCalendar(2004, 6, 9, 13, 45).getTime(); Date dateb = new GregorianCalendar(2004, 6, 9, 13, 45).getTime(); assertTrue(DateUtils.isSameDay(datea, dateb)); dateb = new GregorianCalendar(2004, 6, 10, 13, 45).getTime(); assertFalse(DateUtils.isSameDay(datea, dateb)); datea = new GregorianCalendar(2004, 6, 10, 13, 45).getTime(); assertTrue(DateUtils.isSameDay(datea, dateb)); dateb = new GregorianCalendar(2005, 6, 10, 13, 45).getTime(); assertFalse(DateUtils.isSameDay(datea, dateb)); }
@Test public void testIsSameInstant_Date() { Date datea = new GregorianCalendar(2004, 6, 9, 13, 45).getTime(); Date dateb = new GregorianCalendar(2004, 6, 9, 13, 45).getTime(); assertTrue(DateUtils.isSameInstant(datea, dateb)); dateb = new GregorianCalendar(2004, 6, 10, 13, 45).getTime(); assertFalse(DateUtils.isSameInstant(datea, dateb)); datea = new GregorianCalendar(2004, 6, 10, 13, 45).getTime(); assertTrue(DateUtils.isSameInstant(datea, dateb)); dateb = new GregorianCalendar(2005, 6, 10, 13, 45).getTime(); assertFalse(DateUtils.isSameInstant(datea, dateb)); }
@Test public void testTimestamp() { Type type = TIMESTAMP; Timestamp expected = new Timestamp(new GregorianCalendar(1999, 0, 1, 12, 30, 0).getTime().getTime()); Field f1 = new Field(expected, type); assertEquals(f1.getTimestamp(), expected); assertEquals(f1.getObject(), expected); assertEquals(f1.getType(), type); assertEquals(f1.toString(), "TIMESTAMP '1999-01-01 12:30:00.0'"); Field f2 = new Field(f1); assertEquals(f2, f1); }
@Test public void testDate() { Type type = DATE; Date expected = new Date(new GregorianCalendar(1999, 0, 1).getTime().getTime()); Field f1 = new Field(expected, type); assertEquals(f1.getDate(), expected); assertEquals(f1.getObject(), expected); assertEquals(f1.getType(), type); assertEquals(f1.toString(), "DATE '1999-01-01'"); Field f2 = new Field(f1); assertEquals(f2, f1); }
@Test public void testTime() { Type type = TIME; Time expected = new Time(new GregorianCalendar(1999, 0, 1, 12, 30, 0).getTime().getTime()); Field f1 = new Field(expected, type); assertEquals(f1.getTime(), expected); assertEquals(f1.getObject(), expected); assertEquals(f1.getType(), type); assertEquals(f1.toString(), "TIME '12:30:00'"); Field f2 = new Field(f1); assertEquals(f2, f1); }
@Test public void testRootObject() throws Exception { GregorianCalendar c = new GregorianCalendar(); c.set(1856, 7, 9); // The constructor arguments are name, birthday, and nationaltiy. Inventor tesla = new Inventor("Nikola Tesla", c.getTime(), "Serbian"); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression("name"); StandardEvaluationContext context = new StandardEvaluationContext(); context.setRootObject(tesla); String name = (String) exp.getValue(context); assertEquals("Nikola Tesla",name); }
@Test public void testDayOfMonth() throws Exception { final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 * * ?"); final Date date = new GregorianCalendar(2015, 11, 2).getTime(); final Date fireDate = parser.getNextValidTimeAfter(date); final Date expected = new GregorianCalendar(2015, 11, 2, 7, 0, 0).getTime(); assertEquals("Dates not equal.", expected, fireDate); }
@Test public void testDayOfWeek() throws Exception { final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 ? * Fri"); final Date date = new GregorianCalendar(2015, 11, 2).getTime(); final Date fireDate = parser.getNextValidTimeAfter(date); final Date expected = new GregorianCalendar(2015, 11, 4, 7, 0, 0).getTime(); assertEquals("Dates not equal.", expected, fireDate); }
@Test public void testLastDayOfMonth() throws Exception { final CronExpression parser = new CronExpression("0 */15,12 7-11,13-17 L * ?"); final Date date = new GregorianCalendar(2015, 10, 2).getTime(); final Date fireDate = parser.getNextValidTimeAfter(date); final Date expected = new GregorianCalendar(2015, 10, 30, 7, 0, 0).getTime(); assertEquals("Dates not equal.", expected, fireDate); }