I’m trying to convert a long timestamp that is UTC to Eastern Standard Time and am totally lost. Any hints would be great!
Time format should be : 11/4/03 8:14 PM
Thanks in advance!
TimeZone utcTZ= TimeZone.getTimeZone("UTC");
Calendar utcCal= Calendar.getInstance(utcTZ);
utcCal.setTimeInMillis(utcAsLongValue);
import java.text.SimpleDateFormat;
import java.util.Date;
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzz");
sdf.setTimeZone(utcTZ);
Date utcDate= utcCal.getTime();
sdf.formatDate(utcDate);
Yesterday occasionally I wrote the following method that can help you:
Now you just have to format the date. Use SimpleDateFormat for this. Here is the example: