Java TimeZone Get getConvertDateString(Date date, TimeZone tz, String fmt)

Here you can find the source of getConvertDateString(Date date, TimeZone tz, String fmt)

Description

get Convert Date String

License

Open Source License

Declaration

public static String getConvertDateString(Date date, TimeZone tz, String fmt) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    public static String getConvertDateString(Date date, TimeZone tz, String fmt) {
        if (date == null)
            return null;
        SimpleDateFormat format = new SimpleDateFormat(fmt);
        Date newDete = getConvertDate(date, tz);
        return format.format(newDete);
    }/*from  ww w .ja  v a  2s  .  com*/

    /**
     * Convert date to specified time zone
     * @param date
     * @param tz
     * @return 
     */
    public static Date getConvertDate(Date date, TimeZone tz) {
        if (date == null)
            return null;
        int offset = tz.getRawOffset();
        if (tz.inDaylightTime(date))
            offset += 3600000;
        return new Date(date.getTime() + offset);
    }
}

Related

  1. getAsTimeZone(Map params, String propName)
  2. getAvailableTimezones()
  3. getCal(int dayOfMonth, int month, int year, int hours, int minutes, int seconds, String timezone)
  4. getCalendarForTimeZone(final String timeZone)
  5. getCalendarInstance(TimeZone timeZone, Locale locale)
  6. getCurrentCalendarInTimeZone(final TimeZone timeZone)
  7. getCurrentTimeZone()
  8. getCurrentTimezoneOffset()
  9. getDateInTimeZone(final Date date, final TimeZone timeZone)