Java Long Number to Timestamp toDateTimeString(long timestamp)

Here you can find the source of toDateTimeString(long timestamp)

Description

Converts a timestamp to string yyyy-mm-dd hh:mm:ss

License

Open Source License

Parameter

Parameter Description

Declaration

public static String toDateTimeString(long timestamp) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from   w  w w  . jav a  2 s.  c o  m*/
     * Converts a timestamp to string yyyy-mm-dd hh:mm:ss
     * @param long timestamp unix style timestamp
     */
    public static String toDateTimeString(long timestamp) {
        String DATE_FORMAT = "yyyy-MM-dd";
        String TIME_FORMAT = "HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        SimpleDateFormat stf = new SimpleDateFormat(TIME_FORMAT);
        return sdf.format(new Date(timestamp)) + "T" + stf.format(new Date(timestamp));
    }
}

Related

  1. timestampToHumanDateAndTime(long timestamp)
  2. timestampToString(long micros)
  3. timestampToString(long time)
  4. timestampToString(long timestamp)
  5. timeString(long timestamp)
  6. toSolrTimestamp(Long epoch)
  7. unixTimestampToDate(long timestamp)
  8. unixToDate(final long timestamp)