Java Date RFC Format getRFC3339String(Calendar timestamp)

Here you can find the source of getRFC3339String(Calendar timestamp)

Description

Takes a timestamp as a Calendar and returns it as a String in RFC 3339 format.

License

Open Source License

Parameter

Parameter Description
timestamp a timestamp as a Calendar

Return

the provided timestamp as a RFC 3339 string

Declaration

public static String getRFC3339String(Calendar timestamp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    /**/* w  w  w  .  j  a  va  2  s .c om*/
     * Takes a timestamp as a Calendar and returns it as a String in RFC 3339 format.
     *
     * @param timestamp
     *            a timestamp as a Calendar
     * @return the provided timestamp as a RFC 3339 string
     */
    public static String getRFC3339String(Calendar timestamp) {
        // As of Java 7 this is possible /ib 03/13/2018
        SimpleDateFormat rfc3339Formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
        return rfc3339Formatter.format(timestamp.getTime());
    }
}

Related

  1. get3339Date(String rfc3339Date)
  2. getRFC1123Date()
  3. getRfc1123DateFormat()
  4. getRFC2616Date(Date date)
  5. getRFC822()
  6. getRFC822Date()
  7. getRfc822DateFormat()
  8. getRfc822DateFormat()