Here you can find the source of getUTCDate(Date date)
Parameter | Description |
---|---|
date | the Date object |
public static Date getUTCDate(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { /**// ww w. j a va 2 s.c o m * Converts local time to UTC time properly * @param date the Date object * @return date converted to <b>UTC</b> */ public static Date getUTCDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date.getTime() - cal.getTimeZone().getOffset(date.getTime())); return cal.getTime(); } }