Java Data Type How to - Get current local date in current timezone








Question

We would like to know how to get current local date in current timezone.

Answer

//  www .  j  a v a 2 s  .co m
import java.time.ZoneId;
import java.util.Date;

public class Main {
  public static void main(String[] argv) {
    
    System.out.println(new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
  }
}

The code above generates the following result.