Java Hour Format formatNanosTimeUSEastern(long nanos)

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

Description

format Nanos Time US Eastern

License

Open Source License

Declaration

public static String formatNanosTimeUSEastern(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;
import java.util.Formatter;

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

    public static String formatNanosTimeUSEastern(long nanos) {
        long millis = nanos / 1000000;
        Formatter nanosFormat = new Formatter();
        nanosFormat.format("%06d", nanos - millis * 1000000);
        Date d = new Date(millis);
        synchronized (US_EASTERN_FORMAT_MILLIS) {
            return US_EASTERN_FORMAT_MILLIS.format(d) + nanosFormat.toString();
        }//w w  w  .j a  v a2  s .c  o  m
    }
}

Related

  1. formatInternal(final Date date)
  2. formatInterval(long intervalMsec)
  3. formatLastModified(long lastModifiedTime)
  4. formatMessage(String message)
  5. formatMM(Date date)
  6. formatNewDate(String format)
  7. formatOffset(int offset)
  8. formatOptimal(Date d)
  9. formatPrice(double price, String style)