Java tutorial
//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 { public static String getDateFromUTC(long timestamp) { if (timestamp == 0) timestamp = System.currentTimeMillis(); Date date = new Date(timestamp); Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); cal.setTime(date); String val = (cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.DATE) + " " + cal.get(Calendar.HOUR) + ":" + cal.get(Calendar.MINUTE) + (cal.get(Calendar.AM_PM) == 0 ? "AM" : "PM")); // final Date currentTime = new Date(); // final SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm:ss a z"); // sdf.setTimeZone(TimeZone.getTimeZone("UTC")); // String ret = "UTC time: " + sdf.format(currentTime); // System.out.println(ret); return val; } }