I want to fetch the date and time based on user's location (country basically) and store it in table. For this I have tried below code, but I am not sure it fetches the server time or the timezone of user where he is located. Can someone please guide me to clear this doubt?
@RequestMapping(value = "/tzonee", method = RequestMethod.GET)
public static void main(String[] args) {
// get Calendar instance
Calendar now = Calendar.getInstance();
// get current TimeZone using getTimeZone method of Calendar class
TimeZone timeZone = now.getTimeZone();
Date d = new Date();
timeZone.getID();
System.out.println("in day light time is:" + timeZone.getID());
Calendar c = Calendar.getInstance(TimeZone.getTimeZone(timeZone.getID()));
System.out.println("Timestamp is:" + c.getTime());
// display current TimeZone using getDisplayName() method of TimeZone
// class
System.out.println("Current TimeZone is : " + timeZone.getDisplayName());
}