Code example for Calendar

Methods: get, getTimeZone

0
 
    public static String getDisplayString(String s, Calendar calendar, boolean flag) {
        TimeZone timezone;
        TimeZone timezone1;
        timezone = getSystemTimeZone(s);
        timezone1 = calendar.getTimeZone();
        if(timezone == null) 
        	return null;  
        long l = getOffset(timezone1, calendar);
        long l1 = getOffset(timezone, calendar);
        if(!areTimeZoneIdsEquivalent(timezone.getID(), s) || !flag && l == l1) {
        	return null; 
        } 
        return timezone.getDisplayName();
    } 
 
    private static long getOffset(TimeZone timezone, Calendar calendar) {
        int i = calendar.get(0);
        int j = calendar.get(1);
        int k = calendar.get(5);
        int l = calendar.get(2);
        int i1 = calendar.get(11);
        int j1 = calendar.get(12);
        return (long)timezone.getOffset(i, j, l, k, calendar.get(7), 60000 * (j1 + i1 * 60));
    } 
 
    public static TimeZone getSystemTimeZone(String s) {
        if(!TextUtils.isEmpty(s)) {
        	TimeZone timezone = TimeZone.getTimeZone(s);