Java Second Convert unixtimeToString(long unixSeconds)

Here you can find the source of unixtimeToString(long unixSeconds)

Description

Returns human-readable time string.

License

Open Source License

Parameter

Parameter Description
unixSeconds Unix time in seconds

Return

date and time as string

Declaration

public static String unixtimeToString(long unixSeconds) 

Method Source Code

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

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

public class Main {
    /**/*  w  ww .  j  a  v a 2 s . c o m*/
     * Returns human-readable time string.
     * @param unixSeconds Unix time in seconds
     * @return date and time as string
     */
    public static String unixtimeToString(long unixSeconds) {
        long unixMilliseconds = unixSeconds * 1000L;
        Date date = new java.util.Date(unixMilliseconds);
        SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
        sdf.setTimeZone(java.util.TimeZone.getTimeZone("Europe/Berlin"));
        return sdf.format(date);
    }
}

Related

  1. toSeconds(long milliseconds)
  2. toSeconds(long nanoseconds)
  3. toSeconds(long nanoSeconds)
  4. toSecondsPrecisionInMs(long ms)
  5. toTimeStringNoSeconds(Date timeString)