Here you can find the source of formatXmlDate(Calendar cal)
Parameter | Description |
---|---|
cal | The calendar to format. |
public static String formatXmlDate(Calendar cal)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import javax.xml.bind.DatatypeConverter; public class Main { /**//w w w. j ava 2 s. c o m * Formats a calendar into an XML-formatted date only (without the time). * Example: "2014-02-04" * If null, "null" is returned. * @param cal The calendar to format. * @return A String of the date, or "null" if null. */ public static String formatXmlDate(Calendar cal) { if (cal == null) { return "null"; } // Get the substring, so that the timezone portion is not included. return DatatypeConverter.printDate(cal).substring(0, 10); } }