Here you can find the source of formatCalendar(Calendar calendar)
public static String formatCalendar(Calendar calendar)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.TimeZone; public class Main { public static String formatCalendar(Calendar calendar) { final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS z"; SimpleDateFormat dateFormat = new SimpleDateFormat( DEFAULT_DATE_FORMAT);//w ww . ja v a2s . c om dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(calendar.getTime()); } }