Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

public class Main {
    /**
     * RFC 3339 date format for UTC dates.
     */
    public static final String RFC3339UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    private static ThreadLocal<SimpleDateFormat> RFC3339Formatter = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat(RFC3339UTC, Locale.US);
        }

    };

    public static String formatRFC3339UTC(Date date) {
        SimpleDateFormat format = RFC3339Formatter.get();
        format.applyPattern(RFC3339UTC);
        return format.format(date);
    }
}