Example usage for java.sql Timestamp toLocalDateTime

List of usage examples for java.sql Timestamp toLocalDateTime

Introduction

In this page you can find the example usage for java.sql Timestamp toLocalDateTime.

Prototype

@SuppressWarnings("deprecation")
public LocalDateTime toLocalDateTime() 

Source Link

Document

Converts this Timestamp object to a LocalDateTime .

Usage

From source file:ch.digitalfondue.npjt.mapper.LocalDateTimeMapper.java

private static LocalDateTime toLocalDateTime(Timestamp t) {
    return t != null ? t.toLocalDateTime() : null;
}

From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java

public static LocalTime getLocalTime(final Timestamp timestamp) {
    return timestamp != null ? timestamp.toLocalDateTime().toLocalTime() : null;
}

From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java

public static LocalDateTime getLocalDateTime(final Timestamp timestamp) {
    // empty method
    return timestamp != null ? timestamp.toLocalDateTime() : null;
}

From source file:plugins.Indynet.IndynetResolver.java

private JSONObject buildResolveObject(FreenetURI requestUri, String name) {
    Date date = new java.util.Date();
    JSONObject obj = new JSONObject();
    obj.put("keyType", requestUri.getKeyType());
    obj.put("requestKey", requestUri.toString().split("/")[0]);
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    Timestamp now = new Timestamp(date.getTime());
    obj.put("regTime", now.toLocalDateTime().toString());
    return obj;//  w  w w.  java  2  s . c om
}

From source file:com.teradata.benchto.service.BenchmarkService.java

public Duration getSuccessfulExecutionAge(String uniqueName) {
    Timestamp ended = benchmarkRunRepo.findTimeOfLatestSuccessfulExecution(uniqueName);
    if (ended == null) {
        return Duration.ofDays(Integer.MAX_VALUE);
    }/*from w w  w.j a  v  a  2s  .  com*/
    ZonedDateTime endedAsZDT = ZonedDateTime.of(ended.toLocalDateTime(), ZoneId.systemDefault());
    return Duration.between(endedAsZDT, currentDateTime());
}

From source file:jef.tools.DateUtils.java

/**
 * Converts Timestamp to LocalTime (null safety)
 * @param ts Timestamp/*from   www .j ava 2s .  c  o  m*/
 * @return LocalTime
 */
public static LocalTime toLocalTime(java.sql.Timestamp ts) {
    return ts == null ? null : ts.toLocalDateTime().toLocalTime();
}

From source file:jef.tools.DateUtils.java

/**
 * Converts Timestamp to LocalDateTime (null safety)
 * @param ts Timestamp/*from ww w .  j  a  va2 s . com*/
 * @return LocalDateTime
 */
public static LocalDateTime toLocalDateTime(java.sql.Timestamp ts) {
    return ts == null ? null : ts.toLocalDateTime();
}

From source file:org.apache.storm.sql.compiler.backends.trident.TestPlanCompiler.java

@Test
public void testDateKeywords() throws Exception {
    int EXPECTED_VALUE_SIZE = 1;
    String sql = "SELECT " + "LOCALTIME, CURRENT_TIME, LOCALTIMESTAMP, CURRENT_TIMESTAMP, CURRENT_DATE "
            + "FROM FOO " + "WHERE ID > 0 AND ID < 2";
    TestCompilerUtils.CalciteState state = TestCompilerUtils.sqlOverDummyTable(sql);

    final Map<String, ISqlTridentDataSource> data = new HashMap<>();
    data.put("FOO", new TestUtils.MockSqlTridentDataSource());
    PlanCompiler compiler = new PlanCompiler(data, typeFactory, dataContext);
    final AbstractTridentProcessor proc = compiler.compileForTest(state.tree());
    final TridentTopology topo = proc.build(data);
    Fields f = proc.outputStream().getOutputFields();
    proc.outputStream().partitionPersist(new TestUtils.MockStateFactory(), f, new TestUtils.MockStateUpdater(),
            new Fields());
    runTridentTopology(EXPECTED_VALUE_SIZE, proc, topo);

    long utcTimestamp = (long) dataContext.get(DataContext.Variable.UTC_TIMESTAMP.camelName);
    long currentTimestamp = (long) dataContext.get(DataContext.Variable.CURRENT_TIMESTAMP.camelName);
    long localTimestamp = (long) dataContext.get(DataContext.Variable.LOCAL_TIMESTAMP.camelName);

    System.out.println(getCollectedValues());

    java.sql.Timestamp timestamp = new java.sql.Timestamp(utcTimestamp);
    int dateInt = (int) timestamp.toLocalDateTime().atOffset(ZoneOffset.UTC).toLocalDate().toEpochDay();
    int localTimeInt = (int) (localTimestamp % DateTimeUtils.MILLIS_PER_DAY);
    int currentTimeInt = (int) (currentTimestamp % DateTimeUtils.MILLIS_PER_DAY);

    Assert.assertArrayEquals(/*w  ww  . j a  v a 2 s  . c  o m*/
            new Values[] {
                    new Values(localTimeInt, currentTimeInt, localTimestamp, currentTimestamp, dateInt) },
            getCollectedValues().toArray());
}