Here you can find the source of convertToSystemTime(LocalDateTime userInput, ZoneId userZoneId)
public static Instant convertToSystemTime(LocalDateTime userInput, ZoneId userZoneId)
//package com.java2s; //License from project: Open Source License import java.time.*; import java.util.Objects; public class Main { private static final ZoneId zoneSystem = ZoneId.systemDefault(); public static Instant convertToSystemTime(LocalDateTime userInput, ZoneId userZoneId) { Objects.requireNonNull(userInput, "Local date time is required"); Objects.requireNonNull(userZoneId); ZonedDateTime userTime = ZonedDateTime.of(userInput, userZoneId); ZonedDateTime systemTime = userTime.withZoneSameInstant(zoneSystem); return systemTime.toInstant(); }/*from ww w. j av a 2 s .co m*/ }