Java XML Date dateToString(Date date)

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

Description

date To String

License

LGPL

Declaration

public static String dateToString(Date date) 

Method Source Code

//package com.java2s;
/*/*from w  w w.j a v a 2 s. c om*/
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.xml.bind.DatatypeConverter;

public class Main {
    private static final TimeZone ENCODING_TIME_ZONE = TimeZone
            .getTimeZone("UTC");

    public static String dateToString(Date date) {
        Calendar c = Calendar.getInstance(ENCODING_TIME_ZONE,
                Locale.ENGLISH);
        c.setTime(date);
        return DatatypeConverter.printDateTime(c);
    }
}

Related

  1. convertDate(String date)
  2. dateToDouble(Object value)
  3. dateToString(Date date)
  4. dateToXsdDateTime(Date date)
  5. extractXsdDatetime(String string)
  6. formatXmlDate(Calendar cal)
  7. getDateTimeRepresentation(Calendar date)