Java Data Type How to - Convert LocalDate to java.util.Date in UTC


We would like to know how to convert LocalDate to java.util.Date in UTC.


import java.time.LocalDate;
import java.time.ZoneOffset;
import java.util.Date;
/*ww  w.  j  a  v a2  s.  c om*/
public class Main {

  public static void main(String[] args) {

  public static Date fromLocalDateInUTC(LocalDate date) {
    return Date.from(date.atStartOfDay().toInstant(ZoneOffset.UTC));

The code above generates the following result.