Example usage for java.time OffsetDateTime now

List of usage examples for java.time OffsetDateTime now

Introduction

In this page you can find the example usage for java.time OffsetDateTime now.

Prototype

public static OffsetDateTime now() 

Source Link

Document

Obtains the current date-time from the system clock in the default time-zone.

Usage

From source file:org.jimsey.projects.turbine.fuel.domain.RandomDomainObjectGenerator.java

public RandomDomainObjectGenerator(String market, String symbol) {
    this.market = market;
    this.symbol = symbol;
    this.tick = new TickJson(OffsetDateTime.now(), 100.0d, 101.0d, 90.0d, 100.0d, 100.0d, this.symbol,
            this.market, OffsetDateTime.now().toString());
}

From source file:io.smalldata.ohmageomh.data.service.EndUserServiceImpl.java

@Override
@Transactional//from  w  w  w.j  ava2s  .com
public void registerUser(EndUserRegistrationData registrationData) {

    if (doesUserExist(registrationData.getUsername())) {
        throw new EndUserRegistrationException(registrationData);
    }

    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.TickJsonTest.java

@Test
public void testJsonConstructor() {
    tick = new TickJson(1401174943825l, 99.52d, 99.58d, 98.99d, 99.08d, 100.0d, TurbineTestConstants.MARKET,
            TurbineTestConstants.SYMBOL, OffsetDateTime.now().toString());
    String jsonConstructor = tick.toString();
    tick = new TickJson(OffsetDateTime.now(), 99.52d, 99.58d, 98.99d, 99.08d, 100.0d,
            TurbineTestConstants.MARKET, TurbineTestConstants.SYMBOL, OffsetDateTime.now().toString());
    String tickConstructor = tick.toString();
    logger.info(jsonConstructor);//from  w  w w  .  j  a v a2 s. c  om
    logger.info(tickConstructor);
    assertNotNull(jsonConstructor);
    assertNotNull(tickConstructor);
}

From source file:keywhiz.service.daos.SecretSeriesDAO.java

long createSecretSeries(String name, String creator, String description, @Nullable String type,
        @Nullable Map<String, String> generationOptions) {
    SecretsRecord r = dslContext.newRecord(SECRETS);

    long now = OffsetDateTime.now().toEpochSecond();

    r.setName(name);/* www .  j ava 2  s .  c om*/
    r.setDescription(description);
    r.setCreatedby(creator);
    r.setCreatedat(now);
    r.setUpdatedby(creator);
    r.setUpdatedat(now);
    r.setType(type);
    if (generationOptions != null) {
        try {
            r.setOptions(mapper.writeValueAsString(generationOptions));
        } catch (JsonProcessingException e) {
            // Serialization of a Map<String, String> can never fail.
            throw Throwables.propagate(e);
        }
    } else {
        r.setOptions("{}");
    }
    r.store();

    return r.getId();
}

From source file:org.jimsey.project.turbine.spring.domain.StrategyJsonTest.java

@Test
public void testJsonConstructor() {
    strategy = new StrategyJson(1401174943825l, TurbineTestConstants.SYMBOL, TurbineTestConstants.MARKET,
            100.0d, "exit", "myname", -1, 5, 10.0d, 15.0d, OffsetDateTime.now().toString());
    String jsonConstructor = strategy.toString();
    strategy = new StrategyJson(OffsetDateTime.now(), TurbineTestConstants.SYMBOL, TurbineTestConstants.MARKET,
            100.0d, "exit", "myname", -1, 5, 10.0d, 15.0d, OffsetDateTime.now().toString());
    String strategyConstructor = strategy.toString();
    logger.info(jsonConstructor);/*from www. j a va2  s.c  o  m*/
    logger.info(strategyConstructor);
    assertNotNull(jsonConstructor);
    assertNotNull(strategyConstructor);
}

From source file:keywhiz.service.daos.SecretContentDAO.java

public long createSecretContent(long secretId, String encryptedContent, String creator,
        Map<String, String> metadata, long expiry) {
    SecretsContentRecord r = dslContext.newRecord(SECRETS_CONTENT);

    String jsonMetadata;/*from   www . j ava 2 s  .c om*/
    try {
        jsonMetadata = mapper.writeValueAsString(metadata);
    } catch (JsonProcessingException e) {
        // Serialization of a Map<String, String> can never fail.
        throw Throwables.propagate(e);
    }

    long now = OffsetDateTime.now().toEpochSecond();

    r.setSecretid(secretId);
    r.setEncryptedContent(encryptedContent);
    r.setCreatedby(creator);
    r.setCreatedat(now);
    r.setUpdatedby(creator);
    r.setUpdatedat(now);
    r.setMetadata(jsonMetadata);
    r.setExpiry(expiry);
    r.store();

    return r.getId();
}

From source file:com.example.oauth.AccessToken.java

@Override
public boolean isExpired() {
    final OffsetDateTime now = OffsetDateTime.now();
    return expiration.isBefore(now);
}

From source file:org.jimsey.projects.turbine.condenser.web.IndicatorController.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);
    logger.info("this mornings getIndicatorsAfter() : [{}]",
            getIndicatorsAfter("FTSE100", "ABC", "BollingerBands", sod));
}

From source file:org.jimsey.projects.turbine.fuel.domain.RandomDomainObjectGenerator.java

@Override
public TickJson newTick(OffsetDateTime date) {

    final double variation = 3.0d;

    double open = tick.getClosePrice().toDouble();
    double high = RandomUtils.nextDouble(open, open + variation);
    double low = RandomUtils.nextDouble(Math.max(0, open - variation), open);
    double close = RandomUtils.nextDouble(Math.max(0, low), high);
    double volume = RandomUtils.nextDouble(90, 110);

    tick = new TickJson(date, open, high, low, close, volume, this.symbol, this.market,
            OffsetDateTime.now().toString());
    return tick;/* ww  w. j  a  v  a  2  s.  co m*/
}

From source file:org.jimsey.project.turbine.spring.domain.IndicatorJsonTest.java

@Test
public void testJsonConstructor() {
    indicator = new IndicatorJson(1401174943825l, 100.0d, indicators, TurbineTestConstants.SYMBOL,
            TurbineTestConstants.MARKET, name, OffsetDateTime.now().toString());
    String jsonConstructor = indicator.toString();
    indicator = new IndicatorJson(OffsetDateTime.now(), 100.0d, indicators, TurbineTestConstants.SYMBOL,
            TurbineTestConstants.MARKET, name, OffsetDateTime.now().toString());
    String stockConstructor = indicator.toString();
    logger.info(jsonConstructor);/* w w w. ja v  a 2  s  .co m*/
    logger.info(stockConstructor);
    assertNotNull(jsonConstructor);
    assertNotNull(stockConstructor);
}