List of usage examples for org.joda.time DateTime getMillis
public long getMillis()
From source file:de.iteratec.iteraplan.persistence.dao.HistoryDAOImpl.java
License:Open Source License
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked", "boxing" }) public <T extends BuildingBlock> List<BuildingBlockRevision<T>> getRevisionBounded(final Class<T> entityClass, Integer id, Integer curPage, Integer pageSize, DateTime fromDate, DateTime toDate) { Preconditions.checkArgument(id != null && id.intValue() >= 0, "Param id is invalid, should be >=0"); Preconditions.checkArgument(pageSize >= -1, "Param pageSize is invalid, should be -1 or >0"); Preconditions.checkArgument(pageSize.intValue() != 0, "Param pageSize is invalid, should be -1 or >0"); //would lead to /0 err AuditReader auditReader = getAuditReader(); // Query retrieves RevisionType in addition to Entity; Revs of type DEL are not retrieved // Get date on revisions of this BB AuditQuery curPageQuery = auditReader.createQuery().forRevisionsOfEntity(entityClass, false, false) .add(AuditEntity.id().eq(id)); // Limit results by date if (fromDate != null) { Long fromDateLong = Long.valueOf(fromDate.getMillis()); curPageQuery.add(AuditEntity.revisionProperty(TIMESTAMP_PROPERTY).ge(fromDateLong)); }/* w w w . j a v a 2s. c om*/ if (toDate != null) { Long toDateLong = Long.valueOf(toDate.getMillis()); curPageQuery.add(AuditEntity.revisionProperty(TIMESTAMP_PROPERTY).le(toDateLong)); } int firstResult = curPage * pageSize; // Paging (first results, max results), disabled when requesting all results (pageSize=-1) if (pageSize > 0) { curPageQuery.setFirstResult(firstResult).setMaxResults(pageSize); } // Object Array[3] contains: T, HistoryRevisionEntity, RevisionType List<Object[]> revsList = curPageQuery.addOrder(AuditEntity.revisionNumber().desc()).getResultList(); return Lists.newArrayList(Lists.transform(revsList, new Function<Object[], BuildingBlockRevision<T>>() { @Override public BuildingBlockRevision<T> apply(Object[] revObjects) { return new BuildingBlockRevision<T>(revObjects, entityClass); } })); }
From source file:de.javakaffee.kryoserializers.jodatime.JodaDateTimeSerializer.java
License:Apache License
@Override public void write(final Kryo kryo, final Output output, final DateTime obj) { output.writeLong(obj.getMillis(), true); final String chronologyId = getChronologyId(obj.getChronology()); output.writeString(chronologyId == null ? "" : chronologyId); if (obj.getZone() != null && obj.getZone() != DateTimeZone.getDefault()) output.writeString(obj.getZone().getID()); else//from w w w . ja va2s . co m output.writeString(""); }
From source file:de.javakaffee.web.msm.serializer.javolution.JodaDateTimeFormat.java
License:Apache License
/** * {@inheritDoc}//from w w w . ja va 2 s. c o m */ @Override public void write(final DateTime obj, final javolution.xml.XMLFormat.OutputElement output) throws XMLStreamException { output.setAttribute(MILLIS, obj.getMillis()); final String chronologyId = getChronologyId(obj.getChronology()); if (chronologyId != null) { output.setAttribute(CHRONOLOGY, chronologyId); } if (obj.getZone() != null && obj.getZone() != DateTimeZone.getDefault()) { output.setAttribute(TIME_ZONE, obj.getZone().getID()); } }
From source file:de.kaiserpfalzEdv.infopir.backend.db.BaseEntity.java
License:Apache License
public void setCreatedDate(final DateTime timestamp) { created = new Timestamp(timestamp.getMillis()); }
From source file:de.kaiserpfalzEdv.infopir.backend.db.BaseEntity.java
License:Apache License
public void setLastModifiedDate(final DateTime timestamp) { lastModified = new Timestamp(timestamp.getMillis()); }
From source file:de.kuschku.libquassel.localtypes.orm.converters.DateTimeConverter.java
License:Open Source License
@Override public Long getDBValue(DateTime model) { return model.getMillis(); }
From source file:de.kuschku.libquassel.primitives.serializers.DateTimeSerializer.java
License:Open Source License
@Override public void serialize(@NonNull final ByteChannel channel, @NonNull final DateTime data) throws IOException { final boolean isUTC; final DateTimeZone zone = data.getZone(); if (Objects.equals(zone, DateTimeZone.UTC)) { isUTC = true;// w w w . j a v a2 s . c om } else if (Objects.equals(zone, DateTimeZone.getDefault())) { isUTC = false; // TODO: Add serialization for other timezones } else { throw new IllegalArgumentException( "Serialization of timezones except for local and UTC is not supported"); } IntSerializer.get().serialize(channel, (int) DateTimeUtils.toJulianDayNumber(data.getMillis())); IntSerializer.get().serialize(channel, data.getMillisOfDay()); BoolSerializer.get().serialize(channel, isUTC); }
From source file:de.otto.mongodb.profiler.AbstractAsyncProfiler.java
License:Apache License
@Override public synchronized DateTime continueProfiling(long duration, TimeUnit timeUnit) { if (duration < 1) { throw new IllegalArgumentException("untilInterval must not be lower 1!"); }//w w w. j a v a 2 s. co m if (currentStopProfilingTimeout != null) { throw new IllegalStateException("A timer is already set!"); } if (!continueProfiling()) { return null; } final DateTime until = DateTime.now().plus(timeUnit.toMillis(duration)); stopProfilingTimer.schedule(new StopProfilingTimeout(this, until), new Date(until.getMillis())); return until; }
From source file:de.otto.mongodb.profiler.collection.DefaultCollectionProfile.java
License:Apache License
public void removeMarks(DateTime before) { final long time = before.getMillis(); final Iterator<Mark> marks = this.marks.iterator(); while (marks.hasNext()) { if (marks.next().getTime() < time) { marks.remove();/*from w w w.j a v a 2 s.co m*/ } else { return; } } }