Java Date to String dateToString(Date date)

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

Description

Converts Date type to String based on RFC3339 formatting

License

Apache License

Parameter

Parameter Description
date a parameter

Return

String

Declaration

public static String dateToString(Date date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    /**//from  w w  w . j av  a 2 s  . c  o  m
     * Converts Date type to String based on RFC3339 formatting
     *
     * @param date
     * @return String
     */
    public static String dateToString(Date date) {
        final TimeZone utc = TimeZone.getTimeZone("UTC");

        SimpleDateFormat tformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
        tformat.setTimeZone(utc);
        return tformat.format(date);
    }
}

Related

  1. dateToString(Date date)
  2. dateToString(Date date)
  3. dateToString(Date date)
  4. dateToString(Date date)
  5. dateToString(Date date)
  6. dateToString(Date date)
  7. dateToString(Date date)
  8. dateToString(Date date)
  9. dateToString(Date date)