Here you can find the source of formatToXMLDate(Date date)
public static String formatToXMLDate(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String EAPO_DATE_FORMAT = "yyyy.MM.dd"; public static String formatToXMLDate(Date date) { try {// w w w. j ava 2s . c o m return new SimpleDateFormat("yyyyMMdd").format(date); } catch (Exception e) { return null; } } public static String formatToXMLDate(String date) { try { Date d = new SimpleDateFormat(EAPO_DATE_FORMAT).parse(date); return new SimpleDateFormat("yyyyMMdd").format(d); } catch (Exception e) { return null; } } }