parse Unix Time To Date - Android java.util

Android examples for java.util:Date Parse

Description

parse Unix Time To Date

Demo Code

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

public class Main{

    public static String parseUnixTimeToDate(long unixTimeStamp) {

        long time = unixTimeStamp * (long) 1000;
        Date date = new Date(time);

        // get only the date from the string - June 31, 1969
        DateFormat fmt = new SimpleDateFormat("dd-MM-yyyy");
        String onlyDate = fmt.format(date);

        return onlyDate;

    }/*  ww  w .  ja  va 2s .  c o  m*/

}

Related Tutorials