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








Question

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

Answer

//w  w  w  . j a v  a  2 s  . com
import java.time.LocalDateTime;
import java.time.ZoneId;

public class Main {
    public static void main(String[] args) {
      //Current date in "Asia/Kolkata"
      LocalDateTime todayKolkata = LocalDateTime.now(ZoneId.of("Asia/Kolkata"));
      System.out.println("Current Date in IST="+todayKolkata);
    }
}

The code above generates the following result.