Convert timestamp long to normal date format

Convert timestamp long to normal date format with Time Zone


Use the following imports

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

Within the main function

public static void main(String args[]) {

         Format formatter = new SimpleDateFormat("yyyy MM dd HH:mm:ss Z");
         long timeStamp = 1428676500000L;
         Date date = new Date(timeStamp);
         System.out.println(formatter.format(date));
}

The output is
2015 04 10 09:35:00 -0500

Hope this helps :)



No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days