Java TimeZone Get getTimeZoneByOffSet(String offSetInString)

Here you can find the source of getTimeZoneByOffSet(String offSetInString)

Description

get Time Zone By Off Set

License

Open Source License

Declaration

public static TimeZone getTimeZoneByOffSet(String offSetInString) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {

    public static TimeZone getTimeZoneByOffSet(String offSetInString) {
        String timeZoneID = "";
        Short offSetInShort = Short.parseShort(offSetInString);
        if (offSetInShort > 0) {
            timeZoneID = "GMT+" + offSetInShort;
        } else {/*from w ww  .  ja  va  2  s  .c  o m*/
            timeZoneID = "GMT" + offSetInShort;
        }
        return TimeZone.getTimeZone(timeZoneID);
    }

    public static TimeZone getTimeZoneByOffSet(short offSetInShort) {
        String timeZoneID = "";
        if (offSetInShort > 0) {
            timeZoneID = "GMT+" + offSetInShort;
        } else {
            timeZoneID = "GMT" + offSetInShort;
        }
        return TimeZone.getTimeZone(timeZoneID);
    }
}

Related

  1. getTimeInCurrentDay(long now, TimeZone tz, int hour, int minute, int second, int millisecond)
  2. getTimeTry(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis)
  3. getTimeWithTimeZone(final String timezoneId)
  4. getTimeZone(Calendar cal)
  5. getTimeZone(final String ID)
  6. getTimezoneDifference(String timezone1, String timezone2)
  7. getTimeZoneID()
  8. getTimeZoneIDs()
  9. getTimeZoneOffset()