List of usage examples for java.time Instant now
public static Instant now()
From source file:devbury.dewey.core.web.Main.java
@RequestMapping("/") public String index(Model model) { model.addAttribute("minutes", ChronoUnit.MINUTES.between(startTime, Instant.now())); return "core/index"; }
From source file:cloudfoundry.norouter.f5.PoolDescription.java
public PoolDescription() { this(Instant.now(), Instant.now()); }
From source file:devbury.dewey.core.web.Main.java
@PostConstruct public void init() { startTime = Instant.now(); }
From source file:io.kamax.mxisd.exception.InternalServerError.java
public InternalServerError() { super(HttpStatus.SC_INTERNAL_SERVER_ERROR, "M_UNKNOWN", "An internal server error occured. If this error persists, please contact support with reference #" + Instant.now().toEpochMilli()); }
From source file:com.armeniopinto.time.ApplicationStarter.java
@RequestMapping("/time/{format}") public String time(@PathVariable String format) { final String time; if ("iso".equals(format)) { time = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mmX").withZone(ZoneOffset.UTC) .format(Instant.now()); } else if ("unix".equals(format)) { time = Long.toString(System.currentTimeMillis()); } else if ("pretty".equals(format)) { time = new Date().toString(); } else {/*from w w w. j a va 2 s. c o m*/ throw new IllegalArgumentException(String.format("Unkonwn date format: %s", format)); } return time; }
From source file:fr.inria.atlanmod.neoemf.benchmarks.query.Query.java
default V callWithTime() throws Exception { V result;/*from w w w.j av a 2 s . c om*/ Instant begin = Instant.now(); result = callWithResult(); Instant end = Instant.now(); log.info("Time spent: {}", Duration.between(begin, end)); return result; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
/** * Adds the following headers://from w w w .ja v a 2 s .co m * * <ul> * <li>{@link MessageHeader#MESSAGE_ID} * <li>{@link MessageHeader#MESSAGE_TIMESTAMP} * </ul> * * @return DeliveryOptions */ static DeliveryOptions deliveryOptions() { final DeliveryOptions options = new DeliveryOptions(); options.addHeader(MESSAGE_ID.header, uuid()); options.addHeader(MESSAGE_TIMESTAMP.header, DateTimeFormatter.ISO_INSTANT.format(Instant.now())); options.addHeader(FROM_JVM.header, JVM_ID); return options; }
From source file:ws.salient.model.commands.CommandTest.java
@Before public void before() { kie = KieServices.Factory.get(); json = new ObjectMapper().findAndRegisterModules(); now = Instant.now(); }
From source file:de.loercher.localpress.integration.GeoAndRatingITest.java
@Test public void testAddArticle() { String nowString = "2015-10-12T08:00+02:00[Europe/Berlin]"; ZonedDateTime now = new DateTimeConverter().fromString(nowString); AddArticleEntityDTO geoDTO = new AddArticleEntityDTO(nowString); Instant instant = now.toInstant(); Instant fir = Instant.now(); MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); headers.add("UserID", "ulf"); HttpEntity<AddArticleEntityDTO> request = new HttpEntity<>(geoDTO, headers); RestTemplate template = new RestTemplate(); ResponseEntity<Map> result = template.postForEntity("http://52.29.77.191:8080/localpress/feedback", request, Map.class); Instant afterRating = Instant.now(); GeoBaseEntity.EntityBuilder builder = new GeoBaseEntity.EntityBuilder(); GeoBaseEntity entity = builder.author("ulf") .coordinates(Arrays.asList(new Coordinate[] { new Coordinate(50.1, 8.4) })) .timestamp(now.toEpochSecond()).content("abc.de").title("mein titel").user("ulf").build(); HttpEntity<GeoBaseEntity> second = new HttpEntity<>(entity, headers); System.out.println(result.getBody().get("articleID")); template.put("http://euve33985.vserver.de:8080/geo/" + result.getBody().get("articleID"), second); Instant afterGeoPut = Instant.now(); result = template.getForEntity("http://euve33985.vserver.de:8080/geo/" + result.getBody().get("articleID"), Map.class); Instant afterGeoGet = Instant.now(); assertEquals("User ID has changed over time!", "ulf", result.getBody().get("user")); assertEquals("Content URL has changed over time!", "abc.de", result.getBody().get("content")); DateTimeConverter conv = new DateTimeConverter(); Duration first = Duration.between(fir, afterRating); Duration sec = Duration.between(afterRating, afterGeoPut); Duration third = Duration.between(afterGeoPut, afterGeoGet); System.out.println("Begin: " + conv.toString(now)); System.out.println("Time until POST to rating: " + new Double(first.toMillis()) / 1000); System.out.println("Time until PUT to geo: " + new Double(sec.toMillis()) / 1000); System.out.println("Time until GET to geo: " + new Double(third.toMillis()) / 1000); }
From source file:dk.dbc.rawrepo.oai.ResumptionToken.java
/** * Decode a base64 string (or a json string) into a json object * * @param token resumption token//from ww w.ja v a 2 s . co m * @return object * @throws java.io.IOException Unlikely, ByteArrayInputStream is broken */ public static ObjectNode decode(String token) throws IOException { if (!token.startsWith("{")) { long now = Instant.now().toEpochMilli() / 1000L; String decoded = PackText.decode(token); int indexOf = decoded.indexOf('{'); long epoch = Long.parseLong(decoded.substring(0, indexOf), 16); if (epoch < now) { throw new OAIException(OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN, "ResumptionToken expired"); } token = decoded.substring(indexOf); } try { return (ObjectNode) OBJECT_MAPPER.readTree(token); } catch (IOException ex) { log.error("Exception:" + ex.getMessage()); log.debug("Exception:", ex); throw new OAIException(OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN, "bad token"); } }