format date by timezone - Android java.util

Android examples for java.util:Timezone

Description

format date by timezone

Demo Code

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

public class Main{

    public static String format(String format, Date date, TimeZone timeZone) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        df.setTimeZone(timeZone);/*from  w w w  .  j a  va 2 s  . c o m*/
        return df.format(date);
    }
    public static String format(String format, Date date) {
        return format(format, date, TimeZone.getTimeZone("UTC"));
    }

}

Related Tutorials