Here you can find the source of getFormattedGMTDate(long timestamp)
public static String getFormattedGMTDate(long timestamp)
//package com.java2s; /*//from w ww . j a v a2s . co m * Copyright (C) 2012 CyborgDev <cyborg@alta189.com> * * This file is part of CyborgFactoids * * CyborgFactoids is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * CyborgFactoids is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this. If not, see <http://www.gnu.org/licenses/>. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { private static final DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS z"); public static String getFormattedGMTDate(long timestamp) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.setTimeInMillis(timestamp); return formatter.format(cal.getTime()); } public static String getFormattedGMTDate(Date date) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.setTime(date); return formatter.format(cal.getTime()); } }