将LocalDate设置为现在-
LocalDate date = LocalDate.now();
现在,设置TimeZone偏移量-
ZoneOffset timeZone = ZoneOffset.UTC;
将LocalDate转换为java.util.Date-
Date.from(date.atStartOfDay().toInstant(timeZone))
import java.time.LocalDate; import java.time.ZoneOffset; import java.util.Date; public class Demo { public static void main(String[] args) { LocalDate date = LocalDate.now(); System.out.println("Date = "+date); ZoneOffset timeZone = ZoneOffset.UTC; System.out.println(Date.from(date.atStartOfDay().toInstant(timeZone))); } }
输出结果
Date = 2019-04-19 Fri Apr 19 05:30:00 IST 2019