Here you can find the source of formatTimestampForLogging(final long rawNanosTimestamp)
public static String formatTimestampForLogging(final long rawNanosTimestamp)
//package com.java2s; /**/*from w w w . j av a 2 s. co m*/ * * Copyright (C) 2015 - Daniel Hams, Modular Audio Limited * daniel.hams@gmail.com * * Mad is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Mad is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Mad. If not, see <http://www.gnu.org/licenses/>. * */ public class Main { public static String formatTimestampForLogging(final long rawNanosTimestamp) { final long nanosPart = rawNanosTimestamp % 1000; final long totalMicros = rawNanosTimestamp / 1000; final long microsPart = totalMicros % 1000; final long totalMillis = totalMicros / 1000; final long millisPart = totalMillis % 1000; final long totalSeconds = totalMillis / 1000; final long secondsPart = totalSeconds % 60; final StringBuilder sb = new StringBuilder(3 + 3 + 3 + 3 + 2); sb.append(String.format("%02d", secondsPart)); sb.append("."); sb.append(String.format("%03d", millisPart)); sb.append("."); sb.append(String.format("%03d", microsPart)); sb.append("."); sb.append(String.format("%03d", nanosPart)); return sb.toString(); } }