Here you can find the source of getUniversalDateStamp(Calendar cal)
public static String getUniversalDateStamp(Calendar cal)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /** /*from w w w . j a v a2 s. c o m*/ * Get current time stamp in universal format<br> * Format: yyyy-mm-ddThh:mm:ssZ<br> * e.g.: 1999-09-09T13:10:40Z * @return The Date in the format: yyyy-mm-ddThh:mm:ssZ */ public static String getUniversalDateStamp(long time) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date(time)); return getUniversalDateStamp(cal); } /** * Get current time stamp in universal format<br> * Format: yyyy-mm-ddThh:mm:ssZ<br> * e.g.: 1999-09-09T13:10:40Z * @return The Date in the format: yyyy-mm-ddThh:mm:ssZ */ public static String getUniversalDateStamp(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return getUniversalDateStamp(cal); } /** * Get current time stamp in universal format<br> * Format: yyyy-mm-ddThh:mm:ssZ<br> * e.g.: 1999-09-09T13:10:40Z * @return The Date in the format: yyyy-mm-ddThh:mm:ssZ */ public static String getUniversalDateStamp(Calendar cal) { String year = String.valueOf(cal.get(Calendar.YEAR)); String month = String.valueOf(cal.get(Calendar.MONTH) + 1); if (month.length() == 1) { month = "0" + month; } String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); if (day.length() == 1) { day = "0" + day; } String hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY)); if (hour.length() == 1) { hour = "0" + hour; } String minute = String.valueOf(cal.get(Calendar.MINUTE)); if (minute.length() == 1) { minute = "0" + minute; } String second = String.valueOf(cal.get(Calendar.SECOND)); if (second.length() == 1) { second = "0" + second; } String dateStamp = year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":" + second + "Z"; return dateStamp; } }