Here you can find the source of toUTC(Date date)
Parameter | Description |
---|---|
date | The date to be converted. |
public static Date toUTC(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { /**/*w w w . ja va2 s. c om*/ * Convert the specified date from local time zone to UTC time zone. * @param date The date to be converted. * @return The converted date */ public static Date toUTC(Date date) { Calendar cal = new GregorianCalendar(TimeZone.getDefault()); cal.setTime(date); cal.setTimeZone(TimeZone.getTimeZone("UTC")); return cal.getTime(); } }