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:org.openmrs.module.pharmacyapi.api.prescription.util.NewPrescriptionItemGenerator.java
private Date getExpirationDateMinus2Days(final PrescriptionItem item) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(item.getDrugOrder().getEncounter().getDateCreated()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, 10); while ((calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) || (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)) { calendar.add(Calendar.DAY_OF_MONTH, 1); }/* www.j a va 2s . com*/ return calendar.getTime(); }
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 . j a v a2s . co m*/ 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:fr.syncarnet.tasks.Task.java
/** * Builds a task object giving it a unique UUID and storing the current time as entry date. * @param description/* w w w. j a va 2 s .c o m*/ * The description of the task * @param due * Set it to <b>null</b> if not used * @param project * Set it to <b>null</b> if not used * @param priority * Set it to <b>MEDIUM</b> if not used */ public Task(String description, Calendar due, String project, Priority priority) { this.entry = new Date().getTime(); this.uuid = UUID.randomUUID(); this.description = description; if (due != null) { due.set(Calendar.HOUR_OF_DAY, 0); due.set(Calendar.MINUTE, 0); due.set(Calendar.SECOND, 0); due.set(Calendar.MILLISECOND, 0); } this.due = due; if (project != null && !project.equals("")) { this.project = project; } this.priority = priority; }
From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsLoggingDao.java
/** * Get a {@link Date}, where hours, minutes, seconds and milliseconds are * set to 0.//from ww w.java2 s . c o m * * @return the {@link Date} . */ private static Date getDayStart(final Date d) { final Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE); gc.setTime(d); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc.getTime(); }
From source file:com.square.core.agent.desactivation.relation.DesactivationRelationsAgentJmxThead.java
@Override public void run() { agent.setEtat("Agent DesactivationRelations debut de traitement"); try {// w w w .ja v a 2 s. c o m final Calendar date = Calendar.getInstance(); if (StringUtils.isNotBlank(agent.getDate())) { final SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy"); date.setTime(formatDate.parse(agent.getDate())); } date.clear(Calendar.HOUR); date.clear(Calendar.MINUTE); date.clear(Calendar.SECOND); date.clear(Calendar.MILLISECOND); final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); agent.setEtat("Lancement desactivation relations la date du " + format.format(date.getTime())); int counter = 0; // Cration des criteres des relations dsactiver final RelationCriteresRechercheDto criterias = new RelationCriteresRechercheDto(); criterias.setDateFinMax(date); criterias.setActif(true); criterias.setSupprime(null); // Calcul du nombre total final int nbTotal = personneService.countRelationsParCriteres(criterias); agent.setEtat("Traitement des relations : " + nbTotal + " lments"); // Recuparation des ids de relations List<Long> listeRelationsADesactiver = personneService.rechercherIdsRelationsADesactiver(date, agent.getPagination()); while (listeRelationsADesactiver.size() > 0 && !agent.isStopping()) { counter += listeRelationsADesactiver.size(); logger.debug("Dsactivation des relations en cours " + counter + " / " + nbTotal); personneService.desactiverRelations(listeRelationsADesactiver); // Rcupration des relations dsactiver listeRelationsADesactiver = personneService.rechercherIdsRelationsADesactiver(date, agent.getPagination()); } } catch (Exception e) { agent.setEtat(e.getMessage()); e.printStackTrace(); } finally { agent.getSessionFactory().openSession().close(); agent.stop(); } }
From source file:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.java
public void testLoadMultibleFieldsRecord() { //when reading data having multible field annotations the first field will decide what data to return Calendar someDay = Calendar.getInstance(); someDay.set(2008, 9, 13, 0, 0, 0);//from ww w.j ava 2 s. com someDay.set(Calendar.MILLISECOND, 0); MultibleFieldsRecord loadedRecord = manager.load(MultibleFieldsRecord.class, MULTIBLE_RECORD_DATA); Assert.assertNotNull(loadedRecord); Assert.assertEquals("some ", loadedRecord.getStringData()); Assert.assertEquals(someDay.getTime(), loadedRecord.getDateData()); }
From source file:sk.lazyman.gizmo.util.GizmoUtils.java
public static Date removeOneMilis(Date date) { if (date == null) { return null; }/*from w w w. ja va2 s . c om*/ Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.MILLISECOND, -1); return cal.getTime(); }
From source file:sample.config.MockDataConfig.java
@Bean public Message createMessage() { Calendar created = Calendar.getInstance(Locale.ENGLISH); // we need to clear out the milliseconds since we are not interested in being that precise created.set(Calendar.MILLISECOND, 0); created.getTime().setTime(1397672456000L); Message message = new Message(); message.setCreated(created);/*from www .j a v a 2 s . c o m*/ message.setId(123L); message.setSummary("Spring Rocks"); message.setText("In case you didn't know, Spring Rocks!"); return message; }
From source file:com.lohika.alp.reporter.fe.dao.TestDAOImpl.java
private DetachedCriteria getFilteredCriteria(TestFilter filter) { DetachedCriteria criteria = DetachedCriteria.forClass(Test.class); criteria.createAlias("suite", "suite"); if (filter.getFrom() != null && filter.getTill() != null) { Calendar c = Calendar.getInstance(); c.setTime(filter.getFrom());/*w w w .j a va 2s .co m*/ 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, till)); } if (filter.getTest() != "" && filter.getTest() != null) { try { criteria.add(querytr.translate("name", filter.getTest())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } if (filter.getSuite() != "" && filter.getSuite() != null) { try { criteria.add(querytr.translate("suite.name", filter.getSuite())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } return criteria; }