devxlogo

Time Zone Conversion

Time Zone Conversion

The method below does nothing because the returned Date is exactly the same with the input value.

Always remember that the Date does not carry time zone information, it is always UTC, and the set and get methods convert between UTC and the actual time zone of the Calendar.

public static Date convertTimeZone(Date date, TimeZone timezone) {   Calendar cal = Calendar.getInstance();   cal.setTimeZone(TimeZone.getTimeZone("UTC"));   cal.setTime(date);   cal.setTimeZone(timezone);   return cal.getTime();}
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist