Here you can find the source of dateToUTCDate(Date d)
public static Date dateToUTCDate(Date d)
//package com.java2s; /**//from w w w. ja v a 2s. c o m * Copyright (c) 2009 University of Rochester * * This program is free software; you can redistribute it and/or modify it under the terms of the MIT/X11 license. The text of the * license can be found at http://www.opensource.org/licenses/mit-license.php and copy of the license can be found on the project * website http://www.extensiblecatalog.org/. * */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date dateToUTCDate(Date d) { String strDate = ""; GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(d); int utcOffsetInMinutes = -(calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / (60 * 1000); calendar.add(Calendar.MINUTE, utcOffsetInMinutes); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); return calendar.getTime(); } }