Home » Java » Java: Calculate month end date based on timezone

Java: Calculate month end date based on timezone

Posted by: admin August 11, 2018 Leave a comment

Questions:

I have method to find month end date based on the timezone.

Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("CET"));
calendar.set(
    Calendar.DAY_OF_MONTH, 
    calendar.getActualMaximum(Calendar.DAY_OF_MONTH)
);
System.out.println(calendar.getTime());`

It displays output: Thu Aug 30 18:04:54 PDT 2018.

It should, however, give me an output in CET.

What am I missing?

Answers: