Here you can find the source of formatNanosYearGMT(long nanos)
public static String formatNanosYearGMT(long nanos)
//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*/ } }