Create legacy java.util.Date from Instant
Description
The following code shows how to create legacy java.util.Date from Instant.
Example
import java.time.Clock;
import java.time.Instant;
import java.util.Date;
//from ww w.j a va 2s . c om
public class Main {
public static void main(String... args) {
// get the current time
Clock clock = Clock.systemDefaultZone();
Instant instant = clock.instant();
Date legacyDate = Date.from(instant);
System.out.println(legacyDate);
}
}
The code above generates the following result.