Java Timestamp Format timeToString(long timestamp, SimpleDateFormat format)

Here you can find the source of timeToString(long timestamp, SimpleDateFormat format)

Description

time To String

License

GNU General Public License

Declaration

public static String timeToString(long timestamp, SimpleDateFormat format) 

Method Source Code


//package com.java2s;
/*//  w ww  .  j  a  v  a  2 s. c o  m
 * Title:        StorageCloudSim
 * Description:  StorageCloudSim (Storage as a Service Cloud Simulation), an extension for CloudSim
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 *
 * Copyright (c) 2013, Karlsruhe Institute of Technology, Germany
 * https://github.com/toebbel/StorageCloudSim
 * http://www.tobiassturm.de/projects/storagecloudsim.html
 */

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static SimpleDateFormat defaultDateFormat = new SimpleDateFormat("hh:mm:ss:S");

    public static String timeToString(long timestamp) {
        return timeToString(timestamp, defaultDateFormat);
    }

    public static String timeToString(long timestamp, SimpleDateFormat format) {
        return format.format(new Date(timestamp));
    }
}

Related

  1. timestampFormat(final Date date)
  2. timeStampFormat(Timestamp t)
  3. timestampToFormattedDate(Long timestamp)
  4. timestampToString(final Date ts, final String format, final String tzId)
  5. timestampToString(Long timestamp, String formatStr)
  6. toDateFromTimestamp(String timestamp, String format)
  7. toHumanTime(long timestamp, String format)
  8. toReadableTime(Long timestamp, String format)
  9. toTimeStamp(String dateTime, SimpleDateFormat format, int timeZoneOffset)