List of usage examples for java.util Calendar MINUTE
int MINUTE
To view the source code for java.util Calendar MINUTE.
Click Source Link
get
and set
indicating the minute within the hour. From source file:com.inmobi.messaging.consumer.hadoop.TestConsumerPartitionStartTime.java
@BeforeTest public void setup() throws Exception { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, -30); startTime = cal.getTime();//from w w w . j a v a2 s . c o m config = ClientConfig.loadFromClasspath(firstConfFile); secondconfig = ClientConfig.loadFromClasspath(secondConfFile); firstConsumedMessages = new ArrayList<String>(); secondConsumedMessages = new ArrayList<String>(); createFiles(consumer); chkpointPath = config.getString(HadoopConsumerConfig.checkpointDirConfig); consumer = new HadoopConsumer(); secondConsumer = new HadoopConsumer(); }
From source file:com.aimdek.ccm.dao.impl.test.StatementDaoImplTest.java
/** * Initialize./*from w ww . ja v a 2 s . c om*/ */ @Before public void initialize() { List<Statement> statementList = new ArrayList<Statement>(); Statement statement = new Statement(); statement.setAmountDue(500); statement.setCardNumber("1234-1234-1234-0008"); Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(new Date()); calendar1.add(Calendar.DATE, 15); calendar1.set(Calendar.HOUR_OF_DAY, 23); calendar1.set(Calendar.MINUTE, 59); calendar1.set(Calendar.MINUTE, 59); statement.setDueDate(calendar1.getTime()); statement.setStatementDate(new Date()); Calendar calendar = Calendar.getInstance(); calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); statement.setToDate(calendar.getTime()); statement.setCreditCardId(1); statementList.add(statement); Statement statement1 = new Statement(); statement1.setAmountDue(500); statement1.setCardNumber("1234-1234-1234-0008"); statement1.setDueDate(calendar1.getTime()); statement1.setStatementDate(new Date()); statement1.setToDate(calendar.getTime()); statement1.setCreditCardId(2); statement1.setStatementDate(new Date()); statementList.add(statement1); Statement statement2 = new Statement(); statement2.setAmountDue(500); statement2.setCardNumber("1234-1234-1234-0008"); statement2.setDueDate(calendar1.getTime()); statement2.setStatementDate(new Date()); statement2.setToDate(calendar.getTime()); statement2.setCreditCardId(3); statement2.setStatementDate(new Date()); statementList.add(statement2); Statement statement3 = new Statement(); statement3.setAmountDue(500); statement3.setCardNumber("1234-1234-1234-0008"); statement3.setDueDate(calendar1.getTime()); statement3.setStatementDate(new Date()); statement3.setToDate(calendar.getTime()); statement3.setCreditCardId(3); statement3.setStatementDate(new Date()); statementList.add(statement3); statementRepository.save(statementList); }
From source file:net.servicefixture.converter.XMLGregorianCalendarConverter.java
private XMLGregorianCalendar calendarToXMLGregorianCalendar(Calendar calendar) { XMLGregorianCalendar xmlCal;//w ww . j ava 2 s .c om try { xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(); } catch (DatatypeConfigurationException e) { throw new RuntimeException("Failed to create XMLGregorianCalendar", e); } xmlCal.setYear(calendar.get(Calendar.YEAR)); xmlCal.setMonth(calendar.get(Calendar.MONTH) + 1); xmlCal.setDay(calendar.get(Calendar.DAY_OF_MONTH)); xmlCal.setHour(calendar.get(Calendar.HOUR)); xmlCal.setMinute(calendar.get(Calendar.MINUTE)); xmlCal.setSecond(calendar.get(Calendar.SECOND)); xmlCal.setMillisecond(calendar.get(Calendar.MILLISECOND)); return xmlCal; }
From source file:jp.dip.komusubi.botter.gae.module.FlightStatusTwitter.java
@Override public boolean available(Map<String, List<String>> param) { List<String> values = param.get("route"); // 15??/*w ww .j a va 2 s . co m*/ Calendar limitTime = DateUtils.toCalendar(dateResolver.resolve()); limitTime.add(Calendar.MINUTE, -15); // ??15?????????? flights = new ArrayList<FlightStatus>(); // ?? if (values == null || values.size() == 0) { flights.addAll(flightStatusDao.findByBeforeDeparture(limitTime.getTime())); flights.addAll(flightStatusDao.findByBeforeArrival(limitTime.getTime())); } else { for (String value : values) { // FIXME validate query parameter String[] airports = normalize(value); Route route = routeDao.readByAirportCode(airports[0], airports[1]); if (route == null) { logger.warn("not found Route, " + "query parameter is wrong:{} and {}", airports[0], airports[1]); continue; } flights.addAll(flightStatusDao.findByBeforeDeparture(limitTime.getTime(), value)); flights.addAll(flightStatusDao.findByBeforeArrival(limitTime.getTime(), value)); } } logger.info("delay flight count is {}", flights.size()); return flights.size() > 0; }
From source file:org.activiti.crystalball.simulator.TimerBoundaryEventTest.java
@Test public void testTimerBoundaryEvent() throws Exception { System.setProperty("liveDB", LIVE_DB); System.setProperty("_SIM_DB_PATH", tempDir + "/" + TimerBoundaryEventTest.class.getName() + "-sim-" + Thread.currentThread().getId()); // delete database file File f = new File(System.getProperty("_SIM_DB_PATH") + ".h2.db"); if (!f.delete()) System.err.println("unable to delete file"); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( "/org/activiti/crystalball/simulator/SimEngine-BoundaryTimer-h2-context.xml"); ProcessEngine processEngine = (ProcessEngine) appContext.getBean("simProcessEngine"); // deploy processes processEngine.getRepositoryService().createDeployment() .addClasspathResource("org/activiti/crystalball/simulator/TimerBoundaryEventTest.bpmn").deploy(); SimulationRun simRun = (SimulationRun) appContext.getBean(SimulationRun.class); Calendar c = Calendar.getInstance(); Date startDate = c.getTime(); c.add(Calendar.MINUTE, 5); Date finishDate = c.getTime(); // run simulation for 5 minutes @SuppressWarnings("unused") List<ResultEntity> resultEventList = simRun.execute(startDate, finishDate); TaskService simTaskService = processEngine.getTaskService(); // in 5 minutes 11 processes will be started (0 is included too) assertEquals(11, simTaskService.createTaskQuery().taskDefinitionKey("firstLine").count()); // two tasks were not escalated yet escalation timer is 35sec assertEquals(9, simTaskService.createTaskQuery().taskDefinitionKey("escalation").count()); processEngine.close();// w w w . j a v a2 s . co m appContext.close(); }
From source file:com.sammyun.controller.console.StaticController.java
/** * ???//from w ww . j a v a2 s . com */ @RequestMapping(value = "/build", method = RequestMethod.POST) public @ResponseBody Map<String, Object> build(BuildType buildType, Long articleCategoryId, Long productCategoryId, Date beginDate, Date endDate, Integer first, Integer count, String lang, HttpServletRequest request, HttpServletResponse response) { long startTime = System.currentTimeMillis(); if (beginDate != null) { Calendar calendar = DateUtils.toCalendar(beginDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); beginDate = calendar.getTime(); } if (endDate != null) { Calendar calendar = DateUtils.toCalendar(endDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); endDate = calendar.getTime(); } if (first == null || first < 0) { first = 0; } if (count == null || count <= 0) { count = 50; } int buildCount = 0; boolean isCompleted = true; if (lang == null) { lang = "zh_CN"; } staticService.setLocale(lang); WebUtils.removeCookie(request, response, langCookieName); WebUtils.addCookie(request, response, langCookieName, lang); if (buildType == BuildType.index) { buildCount = staticService.buildIndex(); } else if (buildType == BuildType.article) { } else if (buildType == BuildType.other) { buildCount = staticService.buildOther(); } long endTime = System.currentTimeMillis(); Map<String, Object> map = new HashMap<String, Object>(); map.put("first", first); map.put("buildCount", buildCount); map.put("buildTime", endTime - startTime); map.put("isCompleted", isCompleted); return map; }
From source file:com.ar.dev.tierra.api.service.FacturaService.java
public Page getReservasDay(Integer page, Integer size, int idSucursal) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Date from = calendar.getTime(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); Date to = calendar.getTime(); Page paged = facturaRepository.findReservasByDate(from, to, new PageRequest(page, size), idSucursal); return paged; }
From source file:com.clustercontrol.maintenance.factory.MaintenanceObject.java
/** * ?(dataRetentionPeriod)????00:00:00?epoch()?? * @param dataRetentionPeriod/*from w ww .j av a2 s .c o m*/ * @return */ private Long getDataRetentionBoundary(int dataRetentionPeriod) { m_log.debug("getDataRetentionBoundary() dataRetentionPeriod : " + dataRetentionPeriod); // ??? Calendar calendar = HinemosTime.getCalendarInstance(); // 0?dataRetentionPeriod???? if (dataRetentionPeriod > 0) { calendar.add(Calendar.DATE, -dataRetentionPeriod); } calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Long boundary = calendar.getTimeInMillis(); m_log.debug("getDataRetentionBoundary() : boundary is " + boundary + " (" + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(boundary) + ")"); return boundary; }
From source file:com.lohika.alp.reporter.fe.dao.TestMethodDAOImpl.java
private DetachedCriteria getFilteredCriteria(TestMethodFilter filter) { DetachedCriteria criteria = DetachedCriteria.forClass(TestMethod.class); criteria.createAlias("testInstance", "testInstance").createAlias("testInstance.testClass", "testClass") .createAlias("testInstance.test", "test"); if (filter.getFrom() != null && filter.getTill() != null) { Calendar c = Calendar.getInstance(); c.setTime(filter.getFrom());/*from w w w. j a v a 2s . c om*/ c.set(Calendar.HOUR_OF_DAY, c.getActualMinimum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getActualMinimum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getActualMinimum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getActualMinimum(Calendar.MILLISECOND)); Date from = c.getTime(); c.setTime(filter.getTill()); c.set(Calendar.HOUR_OF_DAY, c.getActualMaximum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getActualMaximum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getActualMaximum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getActualMaximum(Calendar.MILLISECOND)); Date till = c.getTime(); criteria.add(Restrictions.between("startDate", from.getTime(), till.getTime())); } if (filter.getCl() != "" && filter.getCl() != null) { try { criteria.add(querytr.translate("testClass.name", filter.getCl())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } if (filter.getGr() != "" && filter.getGr() != null) { criteria.createAlias("groups", "groups"); try { criteria.add(querytr.translate("groups.name", filter.getGr())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } return criteria; }