Don't do timezone math on the timestamp yourself. Instead, keep it in UTC and set the timezone on the DateFormat
. For example:
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("PDT"));
Date date = new Date(Long.valueOf(dateStr));
String convertedCal = dateFormat.format(date);
By default SimpleDateFormat
uses timezone settings appropriate for the current default locale and that can explain the 1 hour difference you're seeing.