Here you can find the source of getHumanReadable(long ts, boolean addUTC)
Parameter | Description |
---|---|
ts | a parameter |
addUTC | a parameter |
public static String getHumanReadable(long ts, boolean addUTC)
//package com.java2s; /**/*w w w . ja va2 s. c o m*/ * Copyright 2015 Telefonica Investigaci?n y Desarrollo, S.A.U * * This file is part of fiware-cygnus (FI-WARE project). * * fiware-cygnus is free software: you can redistribute it and/or modify it under the terms of the GNU Affero * General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * fiware-cygnus 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 Affero General Public License * for more details. * * You should have received a copy of the GNU Affero General Public License along with fiware-cygnus. If not, see * http://www.gnu.org/licenses/. * * For those usages not covered by the GNU Affero General Public License please contact with iot_support at tid dot es */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** * Gets the human redable version of timestamp expressed in miliseconds. * @param ts * @param addUTC * @return */ public static String getHumanReadable(long ts, boolean addUTC) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); String humanRedable = sdf.format(new Date(ts)); humanRedable += "T"; sdf = new SimpleDateFormat("HH:mm:ss.S"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); humanRedable += sdf.format(new Date(ts)) + (addUTC ? "Z" : ""); return humanRedable; } }