Here you can find the source of formatCalendar(Calendar calendar)
Parameter | Description |
---|---|
calendar | Calendar instance |
public static synchronized String formatCalendar(Calendar calendar)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /**/*from w w w . j ava 2 s . co m*/ * Calendar to String format. * * Method is synchronized because instances of SimpleDateFormat are not thread safe. * * @param calendar Calendar instance * @return Formatted date string as yyyyMMddHHmmss, null if Calendar is null. */ public static synchronized String formatCalendar(Calendar calendar) { if (calendar == null) return null; SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); DATE_FORMAT.setCalendar(calendar); return DATE_FORMAT.format(calendar.getTime()); } }