Here you can find the source of toInstant(final LocalDateTime dateTime)
Parameter | Description |
---|---|
dateTime | The date/time to convert to an Instant . |
public static Instant toInstant(final LocalDateTime dateTime)
//package com.java2s; //License from project: Apache License import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; public class Main { /**/*from w w w . j av a 2 s . c o m*/ * Convert a given {@link LocalDateTime} to an {@link Instant}. In order to convert it, the method * {@link LocalDateTime#toInstant(ZoneOffset)} is called with the offset determined using * {@link ZoneOffset#of(String)} with {@link ZoneOffset#UTC} as argument. * @param dateTime The date/time to convert to an {@link Instant}. * @return The {@link Instant} corresponding to the provided date/time. */ public static Instant toInstant(final LocalDateTime dateTime) { return dateTime.toInstant(ZoneOffset.of(ZoneOffset.UTC.toString())); } }