Java ZonedDateTime to LocalDateTime toUtcLocalDateTime(ZonedDateTime zonedDateTime)

Here you can find the source of toUtcLocalDateTime(ZonedDateTime zonedDateTime)

Description

to Utc Local Date Time

License

Mozilla Public License

Declaration

public static LocalDateTime toUtcLocalDateTime(ZonedDateTime zonedDateTime) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2017 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License, v.
 * 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
 *******************************************************************************/

import java.time.LocalDateTime;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;

import java.util.Date;

public class Main {
    public static LocalDateTime toUtcLocalDateTime(ZonedDateTime zonedDateTime) {
        return zonedDateTime.withZoneSameInstant(ZoneOffset.UTC).toLocalDateTime();
    }/*from   ww w.ja va2  s.c  o  m*/

    public static LocalDateTime toUtcLocalDateTime(Date date) {
        return LocalDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC);
    }
}

Related

  1. toUtcZonedDateTime(LocalDateTime localDateTime)