Apply timezone to Date object

android, java

Solution

use SimpleDateFormat.setTimeZone(TimeZone) to set TimeZone.

    SimpleDateFormat sdf = new SimpleDateFormat("yourformat");   
    TimeZone tz = TimeZone.getDefault(); 
    sdf.setTimeZone(tz);
    sdf.format(yourdate); //will return a string rep of a date with the included format

Problem

``` Date now = new Date(); Date then = new Date((long)obj.timestamp*1000); TimeZone tz = TimeZone.getDefault(); ``` Not very familiar with java, but is there any way to apply a timezone to a `Date` object? I found this thread, but this is about Calendar timezones, which i believe is something different?

Original source

Related problems