Example usage for java.time ZonedDateTime toLocalDateTime

List of usage examples for java.time ZonedDateTime toLocalDateTime

Introduction

In this page you can find the example usage for java.time ZonedDateTime toLocalDateTime.

Prototype

@Override 
public LocalDateTime toLocalDateTime() 

Source Link

Document

Gets the LocalDateTime part of this date-time.

Usage

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    LocalDateTime l = dateTime.toLocalDateTime();
    System.out.println(l);/*from  w w  w . java 2s. com*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime dtPrevistaBR = LocalDateTime.of(2014, 3, 26, 10, 35);

    ZonedDateTime localOrigemZone = ZonedDateTime.of(dtPrevistaBR, ZoneId.systemDefault());

    ZoneId localEntregaZoneId = ZoneId.of("America/Bogota");
    ZonedDateTime dtPrevista = localOrigemZone.withZoneSameInstant(localEntregaZoneId);

    System.out.println("Data Prevista (Brasileira): " + dtPrevistaBR);
    System.out.println("Data Prevista (Bogota): " + dtPrevista.toLocalDateTime());
}

From source file:ExifUtils.ExifReadWrite.java

private static List<meta> exifToMetaIMR(ArrayList<String> filenames, File dir) {
    List<meta> results = new ArrayList<>();
    for (String filename : filenames) {
        ArrayList<String[]> tags;
        String model = null;/* w w w.  j a  v a  2  s  .  c o  m*/
        String note = "";
        String iID = null;
        String dID = null;
        String odID = null;
        String captureDate = null;
        Boolean dateFormat = false;
        try {
            tags = readMeta(new File(dir + "\\" + filename));
        } catch (ImageProcessingException | IOException ex) {
            meta meta = new meta(dir + "\\" + filename, getZonedTimeFromStr(captureDate), dateFormat, model,
                    iID, dID, odID, ex.toString());
            System.out.println(meta);
            results.add(meta);
            continue;
        }
        for (String[] tag : tags) {
            //                System.out.println(tag[0]);
            switch (tag[0]) {
            case "Model":
                model = tag[1];
                break;
            case "xmpMM:InstanceID":
                iID = tag[1];
                break;
            case "xmpMM:DocumentID":
                dID = tag[1];
                break;
            case "xmpMM:OriginalDocumentID":
                odID = tag[1];
                break;
            case "Date/Time Original":
                captureDate = tag[1];
                break;
            case "exif:DateTimeOriginal":
                try {
                    ZonedDateTime wTZ = ZonedDateTime.parse(tag[1], XmpDateFormatTZ);
                    if (LocalDateTime.parse(captureDate, ExifDateFormat).equals(wTZ.toLocalDateTime()))
                        dateFormat = true;
                } catch (DateTimeParseException exc) {
                }
                break;
            }
        }
        meta meta = new meta(dir + "\\" + filename, getZonedTimeFromStr(captureDate), dateFormat, model, iID,
                dID, odID, note);
        System.out.println(meta);
        results.add(meta);
    }
    return results;
}

From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java

public static LocalDateTime toLocalDateTime(Date date) {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(date);/*from  w  w  w . jav a2 s .  c  om*/
    ZonedDateTime zdt = cal.toZonedDateTime();
    return zdt.toLocalDateTime();
}

From source file:ch.digitalfondue.npjt.query.DateTimeQueriesTest.java

private void check(DateQueries dq, String key, ZonedDateTime now) {
    Assert.assertEquals(now, dq.findByKey(key).value);
    Assert.assertEquals(now, dq.findDateByKey(key));
    Assert.assertEquals(now.toLocalDate(), dq.findByKey(key).valueLocalDate);
    Assert.assertEquals(now.toLocalDateTime(), dq.findByKey(key).valueLocalDateTime);
}

From source file:ch.digitalfondue.npjt.query.DateTimeQueriesTest.java

@Test
public void dateQueriesTest() {
    QueryFactory qf = new QueryFactory("hsqldb", new JdbcTemplate(dataSource));

    qf.addColumnMapperFactory(new ZonedDateTimeMapper.Factory());
    qf.addParameterConverters(new ZonedDateTimeMapper.Converter());

    qf.addColumnMapperFactory(new LocalDateMapper.Factory());
    qf.addParameterConverters(new LocalDateMapper.Converter());

    qf.addColumnMapperFactory(new LocalDateTimeMapper.Factory());
    qf.addParameterConverters(new LocalDateTimeMapper.Converter());

    qf.addColumnMapperFactory(new InstantMapper.Factory());
    qf.addParameterConverters(new InstantMapper.Converter());

    DateQueries dq = qf.from(DateQueries.class);

    dq.createTable();//  w  w w. ja v a 2 s  .c  om

    ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));

    dq.insertValue("KEY", now);
    check(dq, "KEY", now);

    dq.insertValue("KEY2", now.toLocalDate());
    check(dq, "KEY2", now.toLocalDate());

    dq.insertValue("KEY3", now.toLocalDateTime());
    check(dq, "KEY3", now);

    Instant iNow = Instant.now();
    dq.insertValue("KEY4", iNow);
    Assert.assertEquals(iNow, dq.findInstantByKey("KEY4"));
    Assert.assertEquals(iNow, dq.findConfInstantByKey("KEY4").value);

}

From source file:nu.yona.server.analysis.service.ActivityUpdateService.java

private Activity createNewActivity(UserAnonymized userAnonymized, ActivityPayload payload, Goal matchingGoal) {
    DayActivity dayActivity = findExistingDayActivity(payload, matchingGoal.getId())
            .orElseGet(() -> createNewDayActivity(userAnonymized, payload, matchingGoal));

    ZonedDateTime endTime = ensureMinimumDurationOneMinute(payload);
    DeviceAnonymized deviceAnonymized = deviceAnonymizedRepository.getOne(payload.deviceAnonymized.getId());
    Activity activity = Activity.createInstance(deviceAnonymized, payload.startTime.getZone(),
            payload.startTime.toLocalDateTime(), endTime.toLocalDateTime(), payload.application);
    activity = activityRepository.save(activity);
    dayActivity.addActivity(activity);/* ww w .  j av  a 2 s .  co m*/
    return activity;
}

From source file:nu.yona.server.analysis.service.ActivityUpdateServiceTest.java

private Activity createActivity(ZonedDateTime startTime, ZonedDateTime endTime) {
    return Activity.createInstance(deviceAnonEntity, userAnonZoneId, startTime.toLocalDateTime(),
            endTime.toLocalDateTime(), Optional.empty());
}

From source file:nu.yona.server.analysis.service.ActivityUpdateServiceTest.java

private Activity createActivity(ZonedDateTime startTime, ZonedDateTime endTime, String app) {
    return Activity.createInstance(deviceAnonEntity, userAnonZoneId, startTime.toLocalDateTime(),
            endTime.toLocalDateTime(), Optional.of(app));
}