Here you can find the source of millis2String(long millis)
public static String millis2String(long millis)
//package com.java2s; /* //from w w w . j av a2 s . c om * SMART FP7 - Search engine for MultimediA enviRonment generated contenT * Webpage: http://smartfp7.eu * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * The Original Code is Copyright (c) 2012-2013 Athens Information Technology * All Rights Reserved * * Contributor: * Nikolaos Katsarakis nkat@ait.edu.gr */ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { static Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); public static String millis2String(long millis) { int fixMillis = 0; String xmlDateTime; /* * If the millis is divisible by 1000, printDateTime does not add a decimal printout. This workaround fixes this * by adding a millisecond before printing */ if (millis % 1000 == 0) fixMillis = 1; synchronized (cal) { cal.setTimeInMillis(millis + fixMillis); xmlDateTime = javax.xml.bind.DatatypeConverter.printDateTime(cal); } // If fixMillis was set to 1, fix the printout if (fixMillis == 1) xmlDateTime = xmlDateTime.replace(".001Z", ".000Z"); return xmlDateTime; } }