Java Date XML Format formatToXMLDate(Date date)

Here you can find the source of formatToXMLDate(Date date)

Description

format To XML Date

License

Open Source License

Declaration

public static String formatToXMLDate(Date date) 

Method Source Code

//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;
        }
    }
}

Related

  1. formatDateToXML(Date dateTime)
  2. formatXml(Date date)
  3. formatXMLDate(Date date, String pattern)
  4. getTime(String xmlDateTime)
  5. getXmlTime(Date date)