Java Data Type How to - Get Current date in "Asia/Kolkata"








Question

We would like to know how to get Current date in "Asia/Kolkata".

Answer

import java.time.LocalDate;
import java.time.ZoneId;
/*from w w  w .ja v a2s  . c o  m*/
public class Main {
    public static void main(String[] args) {
      // Current date in "Asia/Kolkata", you can get it from ZoneId javadoc
      LocalDate todayKolkata = LocalDate.now(ZoneId.of("Asia/Kolkata"));
      System.out.println("Current Date in IST=" + todayKolkata);
    }
}

The code above generates the following result.