getTimeZone ( )源码实例Demo

java.util.Calendar#getTimeZone ( )源码实例Demo

下面列出了java.util.Calendar#getTimeZone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: coming   文件: Arja_00117_s.java
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
源代码2 项目: coming   文件: Elixir_008_s.java
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
源代码3 项目: coming   文件: Arja_0071_t.java
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
源代码4 项目: cloudstack   文件: UsageServiceImpl.java
private Date computeAdjustedTime(Date initialDate, TimeZone targetTZ) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(initialDate);
    TimeZone localTZ = cal.getTimeZone();
    int timezoneOffset = cal.get(Calendar.ZONE_OFFSET);
    if (localTZ.inDaylightTime(initialDate)) {
        timezoneOffset += (60 * 60 * 1000);
    }
    cal.add(Calendar.MILLISECOND, timezoneOffset);

    Date newTime = cal.getTime();

    Calendar calTS = Calendar.getInstance(targetTZ);
    calTS.setTime(newTime);
    timezoneOffset = calTS.get(Calendar.ZONE_OFFSET);
    if (targetTZ.inDaylightTime(initialDate)) {
        timezoneOffset += (60 * 60 * 1000);
    }

    calTS.add(Calendar.MILLISECOND, -1 * timezoneOffset);

    return calTS.getTime();
}
 
源代码5 项目: jdbc-cb   文件: TimestampUtils.java
public Date applyCalendar(Calendar cal, Date date)
{
    // check to see if there is a calendar and that it is different than the one used to parse
    if ( !cal.getTimeZone().hasSameRules(df.getTimeZone()))
    {
        Calendar convertCal = Calendar.getInstance();
        convertCal.setTime(date);
        TimeZone toTimeZone     = cal.getTimeZone();
        TimeZone fromTimeZone   = df.getTimeZone();

        convertCal.setTimeZone(fromTimeZone);
        convertCal.add(Calendar.MILLISECOND, fromTimeZone.getRawOffset() * -1);
        if (fromTimeZone.inDaylightTime(convertCal.getTime())) {
            convertCal.add(Calendar.MILLISECOND, convertCal.getTimeZone().getDSTSavings() * -1);
        }

        convertCal.add(Calendar.MILLISECOND, toTimeZone.getRawOffset());
        if (toTimeZone.inDaylightTime(convertCal.getTime())) {
            convertCal.add(Calendar.MILLISECOND, toTimeZone.getDSTSavings());
        }

        return new Date(convertCal.getTime().getTime());
    }
    return date;
}
 
源代码6 项目: SimFix   文件: 1_FastDateFormat.java
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
源代码7 项目: coming   文件: Arja_0019_s.java
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
源代码8 项目: SimFix   文件: 1_FastDateFormat.java
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    if (mTimeZoneForced) {
        if (mTimeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(mDaylight);
        } else {
            buffer.append(mStandard);
        }
    } else {
        TimeZone timeZone = calendar.getTimeZone();
        if (timeZone.useDaylightTime() && calendar.get(Calendar.DST_OFFSET) != 0) {
            buffer.append(getTimeZoneDisplay(timeZone, true, mStyle, mLocale));
        } else {
            buffer.append(getTimeZoneDisplay(timeZone, false, mStyle, mLocale));
        }
    }
}
 
源代码9 项目: jphp   文件: WrapTime.java
@Signature({
    @Arg(value = "timeZone", nativeType = WrapTimeZone.class, optional = @Optional("NULL")),
    @Arg(value = "locale", nativeType = WrapLocale.class, optional = @Optional("NULL"))
})
public static Memory today(Environment env, Memory... args) {
    Date date1 = new Date();
    Locale aLocale = args[1].isNull() ? Locale.ENGLISH : args[1].toObject(WrapLocale.class).getLocale();
    Calendar calendar = Calendar.getInstance(
            WrapTimeZone.getTimeZone(env, args[0]),
            aLocale
    );
    calendar.setTime(date1);

    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    return new ObjectMemory(new WrapTime(env, calendar.getTime(), calendar.getTimeZone(), aLocale));
}
 
源代码10 项目: coming   文件: Lang_8_FastDatePrinter_t.java
/**
 * {@inheritDoc}
 */
@Override
public void appendTo(StringBuffer buffer, Calendar calendar) {
    TimeZone zone = calendar.getTimeZone();
    if (zone.useDaylightTime()
            && calendar.get(Calendar.DST_OFFSET) != 0) {
        buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
    } else {
        buffer.append(getTimeZoneDisplay(zone, false, mStyle, mLocale));
    }
}
 
源代码11 项目: astor   文件: FastDatePrinter.java
/**
 * {@inheritDoc}
 */
@Override
public void appendTo(StringBuffer buffer, Calendar calendar) {
    TimeZone zone = calendar.getTimeZone();
    if (zone.useDaylightTime()
            && calendar.get(Calendar.DST_OFFSET) != 0) {
        buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
    } else {
        buffer.append(getTimeZoneDisplay(zone, false, mStyle, mLocale));
    }
}
 
源代码12 项目: android_9.0.0_r45   文件: DateFormat.java
private static String getTimeZoneString(Calendar inDate, int count) {
    TimeZone tz = inDate.getTimeZone();
    if (count < 2) { // FIXME: shouldn't this be <= 2 ?
        return formatZoneOffset(inDate.get(Calendar.DST_OFFSET) +
                                inDate.get(Calendar.ZONE_OFFSET),
                                count);
    } else {
        boolean dst = inDate.get(Calendar.DST_OFFSET) != 0;
        return tz.getDisplayName(dst, TimeZone.SHORT);
    }
}
 
源代码13 项目: FoxTelem   文件: ResultSetImpl.java
@Override
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);

    TimeZone tz = cal != null ? cal.getTimeZone() : this.session.getServerSession().getDefaultTimeZone();
    if (this.customTsVf != null && tz == this.lastTsCustomTz) {
        return getDateOrTimestampValueFromRow(columnIndex, this.customTsVf);
    }
    ValueFactory<Timestamp> vf = decorateDateTimeValueFactory(new SqlTimestampValueFactory(cal, tz), this.zeroDateTimeBehavior);
    this.lastTsCustomTz = tz;
    this.customTsVf = vf;
    return getDateOrTimestampValueFromRow(columnIndex, vf);
}
 
源代码14 项目: javaide   文件: GetCurrentTimeZone.java
public static void main(String[] args) {

        //get Calendar instance
        Calendar now = Calendar.getInstance();

        //get current TimeZone using getTimeZone method of Calendar class
        TimeZone timeZone = now.getTimeZone();

        //display current TimeZone using getDisplayName() method of TimeZone class
        System.out.println("Current TimeZone is : " + timeZone.getDisplayName());
    }
 
/** formats time zone specifier. */
private static void formatTimeZone(Calendar cal, StringBuilder buf) {
    TimeZone tz = cal.getTimeZone();

    if (tz == null) {
        return;
    }

    // otherwise print out normally.
    int offset = tz.getOffset(cal.getTime().getTime());

    if (offset == 0) {
        buf.append('Z');
        return;
    }

    if (offset >= 0) {
        buf.append('+');
    } else {
        buf.append('-');
        offset *= -1;
    }

    offset /= 60 * 1000; // offset is in milli-seconds

    formatTwoDigits(offset / 60, buf);
    buf.append(':');
    formatTwoDigits(offset % 60, buf);
}
 
源代码16 项目: xDrip-plus   文件: SetTimeTx.java
public SetTimeTx() {

        final Calendar mCalendar = new GregorianCalendar();
        final TimeZone mTimeZone = mCalendar.getTimeZone();
        this.tzOffset = (mTimeZone.getRawOffset() + (int) getActualDSTOffset(mTimeZone)) / 1000;

        init(OPCODE_SET_TIME, 8);
        this.timestamp = JoH.tsl();
        long time = (timestamp / 1000) - Y2K_EPOCH;
        data.putInt((int) (time & 0xFFFFFFFF));
        data.putInt(tzOffset);
    }
 
源代码17 项目: XACML   文件: ISO8601Date.java
public static ISO8601Date fromCalendar(Calendar calendar) {
	int year;
	if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
		year	= 1 - calendar.get(Calendar.YEAR);
	} else {
		year	= calendar.get(Calendar.YEAR);
	}
	return new ISO8601Date(calendar.getTimeZone(), year, calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH));
}
 
源代码18 项目: lams   文件: ResultSetImpl.java
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);
    ValueFactory<Date> vf = new SqlDateValueFactory(cal != null ? cal.getTimeZone() : this.session.getServerSession().getDefaultTimeZone(), this);
    return getDateOrTimestampValueFromRow(columnIndex, decorateDateTimeValueFactory(vf, this.zeroDateTimeBehavior));
}
 
源代码19 项目: XACML   文件: ISO8601Time.java
public static ISO8601Time fromCalendar(Calendar calendar) {
	return new ISO8601Time(calendar.getTimeZone(), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND), calendar.get(Calendar.MILLISECOND));
}
 
源代码20 项目: org.hl7.fhir.core   文件: InstantType.java
/**
 * Create a new DateTimeDt
 */
public InstantType(Calendar theCalendar) {
	super(theCalendar.getTime(), DEFAULT_PRECISION, theCalendar.getTimeZone());
}