Here you can find the source of getUtcDate(String date, String pattern)
@SuppressWarnings("deprecation") public static String getUtcDate(String date, String pattern)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { @SuppressWarnings("deprecation") public static String getUtcDate(String date, String pattern) { try {/*from ww w . j av a2 s . co m*/ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date now = Calendar.getInstance().getTime(); Date theDate = format.parse(date); theDate.setHours(now.getHours()); theDate.setMinutes(now.getMinutes()); format.setTimeZone(TimeZone.getTimeZone("UTC")); format.applyPattern(pattern); return format.format(theDate); } catch (ParseException e) { throw new RuntimeException(e); } } }