Java Year Format formatNanosYearGMT(long nanos)

Here you can find the source of formatNanosYearGMT(long nanos)

Description

format Nanos Year GMT

License

Open Source License

Declaration

public static String formatNanosYearGMT(long nanos) 

Method Source Code


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

import java.text.DateFormat;

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

public class Main {
    private static DateFormat GMT_FORMAT_YEAR_NO_Z = new SimpleDateFormat("yyyy");
    private static DateFormat GMT_FORMAT_MILLIS_NO_Z = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");

    public static String formatNanosYearGMT(long nanos) {
        long millis = nanos / 1000000;
        Date d = new Date(millis);
        synchronized (GMT_FORMAT_MILLIS_NO_Z) {
            return GMT_FORMAT_YEAR_NO_Z.format(d);
        }/*from  ww w  .j  a v a  2s . c  o m*/
    }
}

Related

  1. formateDate2yyyyMMdd()
  2. formatInyyyyMMdd(java.util.Date date)
  3. formatMdDdYySlashed(Date date)
  4. formatMmDdYyyy(final Date date)
  5. formatMonth(int timeInfo, String yearInfo)
  6. formatSlashedMmDdYy()
  7. formatTimeStampYearFirst(Date date)
  8. formatUniversalMonthYear(Date date)
  9. formatYear(Date d, Locale locale)