Here you can find the source of timestampToString(long micros)
Parameter | Description |
---|---|
micros | the timestamp, in microseconds |
public static String timestampToString(long micros)
//package com.java2s; // Licensed to the Apache Software Foundation (ASF) under one import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final ThreadLocal<DateFormat> DATE_FORMAT = new ThreadLocal<DateFormat>() { @Override/*from w w w. j a va 2s . c o m*/ protected DateFormat initialValue() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); return sdf; } }; /** * Transforms a timestamp into a string, whose formatting and timezone is consistent * across Kudu. * @param micros the timestamp, in microseconds * @return a string, in the format: YYYY-MM-DDTHH:MM:SS.ssssssZ */ public static String timestampToString(long micros) { long tsMillis = micros / 1000L; long tsMicros = micros % 1000000L; String tsStr = DATE_FORMAT.get().format(new Date(tsMillis)); return String.format("%s.%06dZ", tsStr, tsMicros); } }