Example usage for java.time LocalDateTime atZone

List of usage examples for java.time LocalDateTime atZone

Introduction

In this page you can find the example usage for java.time LocalDateTime atZone.

Prototype

@Override
public ZonedDateTime atZone(ZoneId zone) 

Source Link

Document

Combines this date-time with a time-zone to create a ZonedDateTime .

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime now = LocalDateTime.now();
    Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
    Date dateFromOld = Date.from(instant);

    System.out.println(dateFromOld);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    ZonedDateTime b = a.atZone(ZoneId.systemDefault());

    System.out.println(b);//www .  ja  va2s  .  com
}

From source file:Main.java

public static void main(String[] args) {
    Set<String> allZones = ZoneId.getAvailableZoneIds();
    List<String> zoneList = new ArrayList<String>(allZones);
    Collections.sort(zoneList);//from  w  w w .  j a v a 2 s .com

    LocalDateTime dt = LocalDateTime.now();
    for (String s : zoneList) {
        ZoneId zone = ZoneId.of(s);
        ZonedDateTime zdt = dt.atZone(zone);
        ZoneOffset offset = zdt.getOffset();
        String out = String.format("%35s %10s%n", zone, offset);
        System.out.println(out);
    }
}

From source file:org.apdplat.superword.system.AntiRobotFilter.java

public static void main(String[] args) {
    LocalDateTime timePoint = LocalDateTime.now().minusDays(1);
    String date = SIMPLE_DATE_FORMAT.format(Date.from(timePoint.atZone(ZoneId.systemDefault()).toInstant()));
    System.out.println(date);/*from w  w w  . j  a  v  a 2s .  co m*/
}

From source file:Main.java

public static java.sql.Date localTimeToDate(LocalDateTime lt) {
    return new java.sql.Date(lt.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
}

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static Date toDate(LocalDateTime localDateTime) {
    return localDateTime == null ? null : Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}

From source file:org.openhab.binding.plugwise.internal.PlugwiseUtils.java

public static DateTimeType newDateTimeType(LocalDateTime localDateTime) {
    return new DateTimeType(localDateTime.atZone(ZoneId.systemDefault()));
}

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

public static Date getDate(final LocalDateTime localDateTime) {
    Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
    return Date.from(instant);
}

From source file:io.manasobi.utils.DateUtils.java

public static long convertToTimeMillis(LocalDateTime dateTime) {
    ZonedDateTime zdt = dateTime.atZone(ZoneId.of("Asia/Seoul"));
    return zdt.toInstant().toEpochMilli();
}

From source file:com.basp.trabajo_al_minuto.model.business.BusinessUtils.java

public static Date toDate(LocalDateTime localDateTime) throws BusinessException {
    return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}