List of usage examples for java.util Calendar HOUR_OF_DAY
int HOUR_OF_DAY
To view the source code for java.util Calendar HOUR_OF_DAY.
Click Source Link
get
and set
indicating the hour of the day. 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: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/*w w w. j ava 2s .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:net.sourceforge.eclipsetrader.trading.DataCollector.java
public void update(Observable o, Object arg) { Security security = (Security) arg; Quote quote = security.getQuote();//from ww w.ja v a 2 s . c om if (!security.isEnableDataCollector() || quote == null || quote.getDate() == null) return; barTime.setTime(quote.getDate()); barTime.set(Calendar.SECOND, 0); barTime.set(Calendar.MILLISECOND, 0); int quoteTime = barTime.get(Calendar.HOUR_OF_DAY) * 60 + barTime.get(Calendar.MINUTE); if (quoteTime < security.getBeginTime() || quoteTime > security.getEndTime()) return; MapData data = (MapData) map.get(security); if (data.bar != null && data.bar.getDate() != null) { if (barTime.after(data.nextBarTime) || barTime.equals(data.nextBarTime)) { data.history.add(data.bar); if (security.getKeepDays() != 0) { Calendar keepLimit = Calendar.getInstance(); keepLimit.setTime(data.bar.getDate()); keepLimit.set(Calendar.HOUR, 0); keepLimit.set(Calendar.MINUTE, 0); keepLimit.set(Calendar.SECOND, 0); keepLimit.set(Calendar.MILLISECOND, 0); keepLimit.add(Calendar.DATE, -security.getKeepDays()); Date limit = keepLimit.getTime(); while (data.history.size() > 0 && ((Bar) data.history.get(0)).getDate().before(limit)) data.history.remove(0); } try { log.trace("Notifying intraday data updated for " + security.getCode() + " - " + security.getDescription()); data.history.notifyObservers(); data.changes++; if (data.changes >= changes) { CorePlugin.getRepository().save(data.history); data.changes = 0; } } catch (Exception e) { log.error(e, e); } data.bar = null; } } else if (data.bar == null) { data.bar = new Bar(); data.bar.setOpen(quote.getLast()); data.bar.setHigh(quote.getLast()); data.bar.setLow(quote.getLast()); data.bar.setClose(quote.getLast()); data.volume = quote.getVolume(); barTime.add(Calendar.MINUTE, -(barTime.get(Calendar.MINUTE) % minutes)); data.bar.setDate(barTime.getTime()); data.nextBarTime.setTime(data.bar.getDate()); data.nextBarTime.add(Calendar.MINUTE, minutes); } if (data.bar != null) { if (quote.getLast() > data.bar.getHigh()) data.bar.setHigh(quote.getLast()); if (quote.getLast() < data.bar.getLow()) data.bar.setLow(quote.getLast()); data.bar.setClose(quote.getLast()); data.bar.setVolume(quote.getVolume() - data.volume); } }
From source file:org.spring.data.gemfire.cache.UserDataStoreCacheLoader.java
protected static Calendar createCalendar(final int year, final int month, final int dayOfMonth, final int hourOfDay, final int minute, final int second) { Calendar dateTime = Calendar.getInstance(); dateTime.clear();/*from ww w . j av a 2s . c o m*/ dateTime.set(Calendar.YEAR, year); dateTime.set(Calendar.MONTH, month); dateTime.set(Calendar.DAY_OF_MONTH, dayOfMonth); dateTime.set(Calendar.HOUR_OF_DAY, dayOfMonth); dateTime.set(Calendar.MINUTE, minute); dateTime.set(Calendar.SECOND, second); return dateTime; }
From source file:at.florian_lentsch.expirysync.NotifyChecker.java
private static long getFirstStartMillis(Context appContext) { final SharedPreferences sharedPref = appContext.getSharedPreferences("main", Context.MODE_PRIVATE); long firstStartMillis = sharedPref.getLong(SettingsActivity.KEY_ALERT_TIME, -1); if (firstStartMillis == -1) { return -1; }/*w w w . j a v a2 s . com*/ Calendar midnight = Calendar.getInstance(TimeZone.getTimeZone("UTC")); midnight.set(Calendar.HOUR_OF_DAY, 0); midnight.set(Calendar.MINUTE, 0); midnight.set(Calendar.SECOND, 0); midnight.set(Calendar.MILLISECOND, 0); // add "today at 0:00" to the ms value for the alarm (else the alarm // would be scheduled for 1970-01-01): firstStartMillis += midnight.getTimeInMillis(); // if we're already past the alarm time today, we need to add another // day: if (firstStartMillis <= Calendar.getInstance().getTimeInMillis()) { firstStartMillis += AlarmManager.INTERVAL_DAY; } return firstStartMillis; }
From source file:net.chrisrichardson.foodToGo.placeOrderTransactionScripts.dao.RestaurantDAOIBatisImpl.java
public boolean isInServiceArea(String restaurantId, Address deliveryAddress, Date deliveryTime) { Calendar c = Calendar.getInstance(); c.setTime(deliveryTime);/*from www . j a v a 2s .co m*/ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); String zipCode = deliveryAddress.getZip(); Map params = new HashMap(); params.put("zipCode", zipCode); params.put("dayOfWeek", new Integer(dayOfWeek)); params.put("deliveryTime", hour * 100 + minute); params.put("restaurantId", restaurantId); Object result = getSqlMapClientTemplate().queryForObject("isInServiceArea", params); return !new Integer(0).equals(result); }
From source file:it.generatore.DateRandomGaussianGeneratorTest.java
@Test public void testGet() throws Exception { int i = 0;/*from www .j a va 2 s . com*/ int inFascia = 0; int fuoriFascia = 0; Calendar cal = GregorianCalendar.getInstance(); cal.setTimeInMillis(dateRandomGaussianGenerator.minDate); cal = DateUtils.truncate(cal, Calendar.DATE); System.out.println(sdf.format(cal.getTime())); Map<String, Integer> distribuzione = new HashMap<>(); while (++i <= 24 * 60) { cal.add(Calendar.MINUTE, 1); distribuzione.put(getHourKey(cal), 0); } System.out.println(distribuzione.keySet()); i = 0; while (++i <= NUMERO_RECORD) { String strDate = dateRandomGaussianGenerator.get(); //System.out.println("strDate:" + strDate); Matcher m = pattern.matcher(strDate); assertTrue(m.find()); strDate = m.group(1); // System.out.println("strDate:" + strDate); Date date = sdf.parse(strDate); cal.setTime(date); String hourKey = getHourKey(cal); Integer actualValue = distribuzione.get(hourKey); distribuzione.remove(hourKey); distribuzione.put(hourKey, actualValue + 1); if (cal.get(Calendar.HOUR_OF_DAY) >= 9 && cal.get(Calendar.HOUR_OF_DAY) <= 18) { inFascia++; } else { fuoriFascia++; } //System.out.println(strDate); } System.out.println("**** terminato. In fascia: " + inFascia + " fuoriFascia: " + fuoriFascia + " % in fascia: " + (inFascia / NUMERO_RECORD)); assertTrue(inFascia / NUMERO_RECORD >= 0.7d); assertTrue(fuoriFascia / NUMERO_RECORD <= 0.3d); assertTrue(inFascia + fuoriFascia == NUMERO_RECORD); }
From source file:com.intuit.tank.report.JobReportOptions.java
public Date getEndTime() { Date ret = null;//from ww w. ja v a2 s . c o m if (endDate != null) { Calendar cal = Calendar.getInstance(); cal.setTime(endDate); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); if (StringUtils.isNotBlank(endTimeString)) { try { Calendar parsed = Calendar.getInstance(); parsed.setTime(tf.parse(endTimeString)); cal.set(Calendar.HOUR_OF_DAY, parsed.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, parsed.get(Calendar.MINUTE)); } catch (ParseException e) { LOG.warn("Could not parse time string " + startTimeString); } } ret = cal.getTime(); } return ret; }
From source file:com.l2jfree.gameserver.instancemanager.GameTimeManager.java
private GameTimeManager() { new File("data/serial").mkdirs(); final Calendar cal = loadData(); if (cal != null) { _calendar.setTimeInMillis(cal.getTimeInMillis()); } else {// w w w . j av a 2s . com _calendar.set(Calendar.YEAR, 1281); _calendar.set(Calendar.MONTH, 5); _calendar.set(Calendar.DAY_OF_MONTH, 5); _calendar.set(Calendar.HOUR_OF_DAY, 23); _calendar.set(Calendar.MINUTE, 45); saveData(); } ThreadPoolManager.getInstance().scheduleAtFixedRate(new MinuteCounter(), 0, 60000 / Config.DATETIME_MULTI); _log.info("GameTimeController: Initialized."); }