List of usage examples for java.time OffsetDateTime now
public static OffsetDateTime now()
From source file:com.example.oauth.AccessToken.java
@Override public int getExpiresIn() { final OffsetDateTime now = OffsetDateTime.now(); final Duration expiredIn = Duration.between(now, expiration); return (int) expiredIn.get(ChronoUnit.SECONDS); }
From source file:org.jimsey.projects.turbine.condenser.web.TestController.java
@Deprecated @MessageMapping("/request") @SendTo("/topic/reply") public ReplyResponse reply(ReplyResponse message) throws Exception { logger.info("reply({})", message.getMessage()); ReplyResponse response = new ReplyResponse(); // OffsetDateTime.ofInstant(Instant.ofEpochMilli(date), ZoneId.systemDefault()) long date = OffsetDateTime.now().toInstant().toEpochMilli(); response.setMessage(String.format("Hello %s, the time here is %s", message.getMessage(), date)); return response; }
From source file:org.jimsey.project.turbine.spring.domain.TickJsonTest.java
@Test public void testJson() throws IOException { tick = new TickJson(OffsetDateTime.now(), 99.52d, 99.58d, 98.99d, 99.08d, 100.0d, TurbineTestConstants.MARKET, TurbineTestConstants.SYMBOL, OffsetDateTime.now().toString()); String text = json.writeValueAsString(tick); tick = json.readValue(text, TickJson.class); logger.info(text);/*from ww w. j ava 2s . c o m*/ logger.info(tick.toString()); assertEquals(text, tick.toString()); }
From source file:org.jimsey.projects.turbine.condenser.web.TickController.java
@PostConstruct public void init() throws Exception { long sod = OffsetDateTime.now().withHour(0).withMinute(0).withSecond(0).toInstant().toEpochMilli(); long now = OffsetDateTime.now().toInstant().toEpochMilli(); logger.info("right now date value is {}", now); logger.info("this mornings date value is {}", sod); String ticks = getTicks("FTSE100", "ABC"); logger.info("*** getTicks(FTSE100, ABC) : [{}]", ticks); // logger.info("this mornings getTicksAfter(ABC) : [{}]", getTicksAfter("ABC", sod)); }
From source file:org.openmhealth.dsu.service.EndUserServiceImpl.java
@Override @Transactional// ww w .j av a 2 s. c om public void registerUser(EndUserRegistrationData registrationData) { // Determine if username already exists or if e-mail is duplicated if (doesUserExist(registrationData.getUsername()) || doesEmailExist(registrationData.getEmailAddress())) { throw new EndUserRegistrationException(registrationData); } // Create new user EndUser endUser = new EndUser(); endUser.setUsername(registrationData.getUsername()); endUser.setPasswordHash(passwordEncoder.encode(registrationData.getPassword())); endUser.setRegistrationTimestamp(OffsetDateTime.now()); if (registrationData.getEmailAddress() != null) { try { endUser.setEmailAddress(new InternetAddress(registrationData.getEmailAddress())); } catch (AddressException e) { throw new EndUserRegistrationException(registrationData, e); } } endUserRepository.save(endUser); }
From source file:org.jimsey.project.turbine.spring.domain.StrategyJsonTest.java
@Test public void testJson() throws IOException { strategy = new StrategyJson(1401174943825l, TurbineTestConstants.SYMBOL, TurbineTestConstants.MARKET, 100.0d, "enter", "myname", 1, 6, 11.0d, 14.0d, OffsetDateTime.now().toString()); String text = json.writeValueAsString(strategy); strategy = json.readValue(text, StrategyJson.class); logger.info(text);// w ww.j a v a2 s .co m logger.info(strategy.toString()); assertEquals(text, strategy.toString()); }
From source file:keywhiz.service.daos.SecretSeriesDAO.java
void updateSecretSeries(long secretId, String name, String creator, String description, @Nullable String type, @Nullable Map<String, String> generationOptions) { long now = OffsetDateTime.now().toEpochSecond(); if (generationOptions == null) { generationOptions = ImmutableMap.of(); }/* w w w . ja v a 2 s .c o m*/ try { dslContext.update(SECRETS).set(SECRETS.NAME, name).set(SECRETS.DESCRIPTION, description) .set(SECRETS.UPDATEDBY, creator).set(SECRETS.UPDATEDAT, now).set(SECRETS.TYPE, type) .set(SECRETS.OPTIONS, mapper.writeValueAsString(generationOptions)) .where(SECRETS.ID.eq(secretId)).execute(); } catch (JsonProcessingException e) { // Serialization of a Map<String, String> can never fail. throw Throwables.propagate(e); } }
From source file:org.jimsey.project.turbine.spring.domain.IndicatorJsonTest.java
@Test public void testJson() throws IOException { indicator = new IndicatorJson(OffsetDateTime.now(), 100.0d, indicators, TurbineTestConstants.SYMBOL, TurbineTestConstants.MARKET, name, OffsetDateTime.now().toString()); String text = json.writeValueAsString(indicator); indicator = json.readValue(text, IndicatorJson.class); logger.info(text);/* w w w . j a v a2 s. co m*/ logger.info(indicator.toString()); assertEquals(text, indicator.toString()); }
From source file:org.jimsey.project.turbine.spring.domain.TickJsonTest.java
@Ignore @Test/* w w w . j a va 2 s. co m*/ public void testSerializable() throws IOException { tick = new TickJson(OffsetDateTime.now(), 99.52d, 99.58d, 98.99d, 99.08d, 100.0d, TurbineTestConstants.MARKET, TurbineTestConstants.SYMBOL, OffsetDateTime.now().toString()); byte[] bytes = SerializationUtils.serialize(tick); TickJson tick2 = (TickJson) SerializationUtils.deserialize(bytes); logger.info(tick.toString()); logger.info(tick2.toString()); }
From source file:org.jimsey.projects.turbine.fuel.domain.RandomDomainObjectGenerator.java
@Override public IndicatorJson newIndicator(OffsetDateTime date, String name) { final double variation = 3.0d; double open = tick.getClose(); double high = tick.getHigh(); double low = tick.getLow(); double closePriceIndicator = tick.getClose(); Map<String, Double> indicators = new HashMap<>(); indicators.put("upper", RandomUtils.nextDouble(open, open + variation)); indicators.put("lower", RandomUtils.nextDouble(Math.max(0, open - variation), open)); indicators.put("middle", RandomUtils.nextDouble(Math.max(0, low), high)); indicator = new IndicatorJson(date, closePriceIndicator, indicators, this.symbol, this.market, name, OffsetDateTime.now().toString()); return indicator; }