Java TimeZone Get getTimeAsPerTimeZone(String time, String timeZOne)

Here you can find the source of getTimeAsPerTimeZone(String time, String timeZOne)

Description

Gets the time as per time zone.

License

Open Source License

Parameter

Parameter Description
time the time
timeZOne the time z one

Return

the time as per time zone

Declaration

public static String getTimeAsPerTimeZone(String time, String timeZOne) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.GregorianCalendar;
import java.util.TimeZone;

public class Main {
    /**/*from  www  .j  a  v  a2s .c o m*/
     * Gets the time as per time zone.
     * 
     * @param time
     *            the time
     * @param timeZOne
     *            the time z one
     * @return the time as per time zone
     */
    public static String getTimeAsPerTimeZone(String time, String timeZOne) {
        time = time.split("Minutes")[1];
        DateFormat formatter = new SimpleDateFormat("hh:mm a");
        TimeZone tz = TimeZone.getTimeZone("EST5EDT");
        Calendar cal = new GregorianCalendar(tz);
        cal.add(Calendar.MINUTE, Integer.parseInt(time));
        formatter.setTimeZone(tz);
        return formatter.format(cal.getTime());
    }
}

Related

  1. getServerTimezoneOffset()
  2. getTime(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, boolean setMillis, int nano)
  3. getTime(final String time, final TimeZone tz)
  4. getTime(TimeZone tz, int year, int month, int day, int hour, int minute, int second)
  5. getTime(TimeZone zone)
  6. getTimeInCurrentDay(long now, TimeZone tz, int hour, int minute, int second, int millisecond)
  7. getTimeTry(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis)
  8. getTimeWithTimeZone(final String timezoneId)
  9. getTimeZone(Calendar cal)