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:lineage2.gameserver.model.entity.events.impl.ClanHallAuctionEvent.java
/** * Method reCalcNextTime.//w ww . j a v a2 s. c o m * @param onStart boolean */ @Override public void reCalcNextTime(boolean onStart) { clearActions(); _onTimeActions.clear(); Clan owner = getResidence().getOwner(); _endSiegeDate.setTimeInMillis(0); if ((getResidence().getAuctionLength() == 0) && (owner == null)) { getResidence().getSiegeDate().setTimeInMillis(System.currentTimeMillis()); getResidence().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); getResidence().getSiegeDate().set(Calendar.HOUR_OF_DAY, 15); getResidence().getSiegeDate().set(Calendar.MINUTE, 0); getResidence().getSiegeDate().set(Calendar.SECOND, 0); getResidence().getSiegeDate().set(Calendar.MILLISECOND, 0); getResidence().setAuctionLength(7); getResidence().setAuctionMinBid(getResidence().getBaseMinBid()); getResidence().setJdbcState(JdbcEntityState.UPDATED); getResidence().update(); _onTimeActions.clear(); addOnTimeAction(0, new StartStopAction(EVENT, true)); addOnTimeAction(getResidence().getAuctionLength() * 86400, new StartStopAction(EVENT, false)); _endSiegeDate.setTimeInMillis(getResidence().getSiegeDate().getTimeInMillis() + (getResidence().getAuctionLength() * 86400000L)); registerActions(); } else if ((getResidence().getAuctionLength() == 0) && (owner != null)) { } else { long endDate = getResidence().getSiegeDate().getTimeInMillis() + (getResidence().getAuctionLength() * 86400000L); if (endDate <= System.currentTimeMillis()) { getResidence().getSiegeDate().setTimeInMillis(System.currentTimeMillis()); } _endSiegeDate.setTimeInMillis(getResidence().getSiegeDate().getTimeInMillis() + (getResidence().getAuctionLength() * 86400000L)); _onTimeActions.clear(); addOnTimeAction(0, new StartStopAction(EVENT, true)); addOnTimeAction(getResidence().getAuctionLength() * 86400, new StartStopAction(EVENT, false)); registerActions(); } }
From source file:net.seratch.taskun.util.CalendarUtil.java
public static Calendar dateTrunc(Calendar calendar) { if (calendar == null) { return null; }//from w w w . j a v a2s . c o m Calendar date = (Calendar) calendar.clone(); date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); return date; }
From source file:Dates.java
/** * Puts hours, minutes, seconds and milliseconds to zero. <p> * //from ww w . jav a 2 s. c om * @return The same date sent as argument (a new date is not created). If null * if sent a null is returned. */ public static Date removeTime(Date date) { if (date == null) return null; Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); date.setTime(cal.getTime().getTime()); return date; }
From source file:sk.lazyman.gizmo.util.GizmoUtils.java
public static Date clearTime(Date date) { if (date == null) { return null; }//from ww w . j a v a 2s. co m Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Clock.java
public void paintComponent(Graphics g) { super.paintComponent(g); Color colorRetainer = g.getColor(); g.setColor(getBackground());// w w w. j av a2 s .co m g.fillRect(0, 0, getWidth(), getHeight()); getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight()); calendar.setTime(new Date()); // get current time int hrs = calendar.get(Calendar.HOUR_OF_DAY); int min = calendar.get(Calendar.MINUTE); g.setColor(getForeground()); if (isDigital) { String time = "" + hrs + ":" + min; g.setFont(getFont()); FontMetrics fm = g.getFontMetrics(); int y = (getHeight() + fm.getAscent()) / 2; int x = (getWidth() - fm.stringWidth(time)) / 2; g.drawString(time, x, y); } else { int x = getWidth() / 2; int y = getHeight() / 2; int rh = getHeight() / 4; int rm = getHeight() / 3; double ah = ((double) hrs + min / 60.0) / 6.0 * Math.PI; double am = min / 30.0 * Math.PI; g.drawLine(x, y, (int) (x + rh * Math.sin(ah)), (int) (y - rh * Math.cos(ah))); g.drawLine(x, y, (int) (x + rm * Math.sin(am)), (int) (y - rm * Math.cos(am))); } g.setColor(colorRetainer); }
From source file:com.pivotal.gfxd.demo.loader.Loader.java
public void insertBatch(final List<String[]> lines, final long timestamp) { String sql = "insert into raw_sensor (id, timestamp, value, property, plug_id, household_id, house_id, weekday, time_slice) values (?,?,?,?,?,?,?,?,?)"; final Calendar cal = Calendar.getInstance(); getJdbcTemplate().batchUpdate(sql, new BatchPreparedStatementSetter() { @Override//from w w w. jav a 2s . c o m public void setValues(PreparedStatement ps, int i) throws SQLException { final String[] split = lines.get(i); int plugId = Integer.parseInt(split[4]); int householdId = Integer.parseInt(split[5]); int houseId = Integer.parseInt(split[6]); ps.setLong(1, Long.parseLong(split[0])); ps.setLong(2, timestamp); float value = Float.parseFloat(split[2]); ps.setFloat(3, value + value * disturbance); ps.setInt(4, Integer.parseInt(split[3])); ps.setInt(5, computePlugId(plugId, householdId, houseId)); ps.setInt(6, householdId); ps.setInt(7, houseId); cal.setTimeInMillis(timestamp * 1000L); int weekDay = cal.get(Calendar.DAY_OF_WEEK); int timeSlice = (cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE)) / MINUTES_PER_INTERVAL; ps.setInt(8, weekDay); // weekday ps.setInt(9, timeSlice); // time_slice } @Override public int getBatchSize() { return lines.size(); } }); cal.setTimeInMillis(timestamp * 1000L); int weekDay = cal.get(Calendar.DAY_OF_WEEK); int timeSlice = (cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE)) / MINUTES_PER_INTERVAL; LOG.debug("rows=" + lines.size() + " weekday=" + weekDay + " slice=" + timeSlice + " stamp=" + timestamp + " now=" + (int) (System.currentTimeMillis() / 1000)); rowsInserted += lines.size(); }
From source file:com.l2jfree.gameserver.instancemanager.RecommendationManager.java
private RecommendationManager() { Calendar update = Calendar.getInstance(); if (update.get(Calendar.HOUR_OF_DAY) >= 13) update.add(Calendar.DAY_OF_MONTH, 1); update.set(Calendar.HOUR_OF_DAY, 13); nextUpdate = update.getTimeInMillis(); ThreadPoolManager.getInstance().schedule(new RecommendationUpdater(), nextUpdate - System.currentTimeMillis()); _log.info("RecommendationManager: initialized."); }
From source file:io.github.microcks.listener.DailyStatisticsFeederTest.java
@Test public void testOnApplicationEvent() { Calendar today = Calendar.getInstance(); MockInvocationEvent event = new MockInvocationEvent(this, "TestService1", "1.0", "123456789", today.getTime(), 100);//from ww w . j ava 2s . co m // Fire event a first time. feeder.onApplicationEvent(event); SimpleDateFormat formater = new SimpleDateFormat("yyyyMMdd"); String day = formater.format(today.getTime()); DailyStatistic stat = statisticsRepository.findByDayAndServiceNameAndServiceVersion(day, "TestService1", "1.0"); assertNotNull(stat); assertNotNull(stat.getId()); assertEquals(day, stat.getDay()); assertEquals("TestService1", stat.getServiceName()); assertEquals("1.0", stat.getServiceVersion()); assertEquals(1, stat.getDailyCount()); assertEquals(new Integer(1), stat.getHourlyCount().get(String.valueOf(today.get(Calendar.HOUR_OF_DAY)))); // Fire event a second time. feeder.onApplicationEvent(event); stat = statisticsRepository.findByDayAndServiceNameAndServiceVersion(day, "TestService1", "1.0"); assertNotNull(stat); assertNotNull(stat.getId()); assertEquals(day, stat.getDay()); assertEquals("TestService1", stat.getServiceName()); assertEquals("1.0", stat.getServiceVersion()); assertEquals(2, stat.getDailyCount()); assertEquals(new Integer(2), stat.getHourlyCount().get(String.valueOf(today.get(Calendar.HOUR_OF_DAY)))); }
From source file:io.wcm.devops.conga.plugins.aem.util.JsonContentLoaderTest.java
@Test public void testCalendarEcmaFormat() { Map<String, Object> props = getDeep(content, "jcr:content"); Calendar calendar = (Calendar) props.get("cq:lastModified"); assertNotNull(calendar);/*from w w w . j a v a2 s . com*/ calendar.setTimeZone(TimeZone.getTimeZone("GMT+2")); assertEquals(2014, calendar.get(Calendar.YEAR)); assertEquals(4, calendar.get(Calendar.MONTH) + 1); assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH)); assertEquals(15, calendar.get(Calendar.HOUR_OF_DAY)); assertEquals(11, calendar.get(Calendar.MINUTE)); assertEquals(24, calendar.get(Calendar.SECOND)); }