Java Unix Date unixTimeToDate(long unixTime)

Here you can find the source of unixTimeToDate(long unixTime)

Description

unix Time To Date

License

Open Source License

Declaration

public static Date unixTimeToDate(long unixTime) 

Method Source Code


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

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static Date unixTimeToDate(long unixTime) {
        //long unixSeconds = 1372339860;
        Date date = new Date(unixTime * 1000L); // *1000 is to convert seconds to milliseconds
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); // the format of your date
        //sdf.setTimeZone(TimeZone.getTimeZone("GMT+3")); // give a timezone reference for formating (see comment at the bottom
        String formattedDate = sdf.format(date);
        System.out.println(formattedDate);
        return date;
    }/* w  w w .  ja  v  a 2  s .  co  m*/
}

Related

  1. parseUnixDate(String paramName, String dateStr)
  2. stringUnixTime(String start, String end)
  3. toUnixTime(Date date)
  4. toUnixTime(SimpleDateFormat simpleDateFormat, String audioboxDate)
  5. unixTime()
  6. unixTimeToDateInt(long unixTime)
  7. unixTimeToString(int time)