List of usage examples for java.time Instant ofEpochMilli
public static Instant ofEpochMilli(long epochMilli)
From source file:com.fizzed.stork.deploy.DeployHelper.java
static public String toVersionDateTime(long millis) { Instant instant = Instant.ofEpochMilli(millis); LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC); return ldt.format(versionDateTimeFormatter); }
From source file:edu.usu.sdl.openstorefront.common.util.TimeUtil.java
/** * Get the start of the day passed in/*from w ww . ja v a 2 s. co m*/ * * @param date * @return beginning of day or null if date was null */ public static Date beginningOfDay(Date date) { if (date != null) { Instant instant = Instant.ofEpochMilli(date.getTime()).truncatedTo(ChronoUnit.DAYS); return new Date(instant.toEpochMilli()); } return date; }
From source file:pe.edu.system.jcmr.util.UtilidadesFx.java
public static LocalDate converterDateToLocalDate(Date date) { Instant instant = Instant.ofEpochMilli(date.getTime()); LocalDate localDate = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate(); return localDate; }
From source file:net.NET_INFO.java
/** * ? LocalDateTime/*from www . jav a 2 s .c om*/ * @return the current date-time using the system clock and default time-zone. */ public static LocalDateTime getCurrentTime() { return LocalDateTime.ofInstant(Instant.ofEpochMilli(getCurrentMilli()), ZoneId.systemDefault()); }
From source file:org.structr.rest.auth.SessionHelper.java
public static boolean isSessionTimedOut(final HttpSession session) { if (session == null) { return true; }/* w ww . j ava 2 s .com*/ final long now = (new Date()).getTime(); try { final long lastAccessed = session.getLastAccessedTime(); if (now > lastAccessed + Services.getGlobalSessionTimeout() * 1000) { logger.debug("Session {} timed out, last accessed at {}", new Object[] { session.getId(), Instant.ofEpochMilli(lastAccessed).toString() }); return true; } return false; } catch (IllegalStateException ise) { return true; } }
From source file:com.fizzed.stork.deploy.DeployHelper.java
static public String toFriendlyDateTime(long millis) { Instant instant = Instant.ofEpochMilli(millis); LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC); return ldt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); }
From source file:fr.javatic.mongo.jacksonCodec.javaTime.deserializers.InstantDeserializer.java
@Override public Instant deserialize(BsonParser bsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (bsonParser.getCurrentToken() != JsonToken.VALUE_EMBEDDED_OBJECT || bsonParser.getCurrentBsonType() != BsonConstants.TYPE_DATETIME) { ctxt.mappingException(Date.class); }/* w ww . jav a 2 s . co m*/ Object obj = bsonParser.getEmbeddedObject(); if (obj == null) { return null; } Date dt = (Date) obj; return Instant.ofEpochMilli(dt.getTime()); }
From source file:io.curly.advisor.integration.event.CreatedReviewHandler.java
@Override public void onApplicationEvent(CreatedReview event) { final Object source = event.getSource(); if (log.isDebugEnabled()) { log.debug("Received application event with source {} at {}", source, LocalDateTime.ofInstant(Instant.ofEpochMilli(event.getTimestamp()), ZoneId.systemDefault())); }/*w w w . j a v a 2s . co m*/ if (source instanceof Review) { final Review review = (Review) source; reviewEventEmitter.emmit(review); } else { log.warn("Application event source is not instance of review cannot emmit it!"); } }
From source file:fr.javatic.mongo.jacksonCodec.javaTime.deserializers.ZonedDateTimeDeserializer.java
@Override public ZonedDateTime deserialize(BsonParser bsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (bsonParser.getCurrentToken() != JsonToken.VALUE_EMBEDDED_OBJECT || bsonParser.getCurrentBsonType() != BsonConstants.TYPE_DATETIME) { throw ctxt.mappingException(Date.class); }//from ww w . j ava 2s.c o m Object obj = bsonParser.getEmbeddedObject(); if (obj == null) { return null; } Date dt = (Date) obj; return Instant.ofEpochMilli(dt.getTime()).atZone(ZoneId.of("UTC")); }
From source file:fr.javatic.mongo.jacksonCodec.javaTime.deserializers.OffsetDateTimeDeserializer.java
@Override public OffsetDateTime deserialize(BsonParser bsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (bsonParser.getCurrentToken() != JsonToken.VALUE_EMBEDDED_OBJECT || bsonParser.getCurrentBsonType() != BsonConstants.TYPE_DATETIME) { throw ctxt.mappingException(Date.class); }/*from w w w.j a v a2 s .com*/ Object obj = bsonParser.getEmbeddedObject(); if (obj == null) { return null; } Date dt = (Date) obj; return Instant.ofEpochMilli(dt.getTime()).atOffset(ZoneOffset.UTC); }