本文整理汇总了Java中java.util.Calendar.getTimeZone方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.getTimeZone方法的具体用法?Java Calendar.getTimeZone怎么用?Java Calendar.getTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Calendar
的用法示例。
在下文中一共展示了Calendar.getTimeZone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendTo
import java.util.Calendar; //导入方法依赖的package包/类
/**
* {@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: appendTo
import java.util.Calendar; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
final 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));
}
}
示例3: main
import java.util.Calendar; //导入方法依赖的package包/类
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());
}
示例4: TransactionInfoAdapter
import java.util.Calendar; //导入方法依赖的package包/类
public TransactionInfoAdapter(Context context, OnInteractionListener listener) {
this.context = context;
inboundColour = ContextCompat.getColor(context, R.color.tx_green);
outboundColour = ContextCompat.getColor(context, R.color.tx_red);
pendingColour = ContextCompat.getColor(context, R.color.tx_pending);
failedColour = ContextCompat.getColor(context, R.color.tx_failed);
infoItems = new ArrayList<>();
this.listener = listener;
Calendar cal = Calendar.getInstance();
TimeZone tz = cal.getTimeZone(); //get the local time zone.
DATETIME_FORMATTER.setTimeZone(tz);
}
示例5: WalletInfoAdapter
import java.util.Calendar; //导入方法依赖的package包/类
public WalletInfoAdapter(Context context, OnInteractionListener listener) {
this.context = context;
this.infoItems = new ArrayList<>();
this.listener = listener;
Calendar cal = Calendar.getInstance();
TimeZone tz = cal.getTimeZone(); //get the local time zone.
DATETIME_FORMATTER.setTimeZone(tz);
}
示例6: formatTimeZone
import java.util.Calendar; //导入方法依赖的package包/类
/** 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);
}
示例7: truncateDate
import java.util.Calendar; //导入方法依赖的package包/类
/**
* @param date
* @param truncateAt
*/
public static Date truncateDate(final Date date, final int truncateAt) {
final Calendar source = Calendar.getInstance();
source.clear();
source.setTime(date);
final Calendar result = Calendar.getInstance();
result.clear();
result.set(Calendar.YEAR, source.get(Calendar.YEAR));
final TimeZone sourceTimeZone = source.getTimeZone();
result.setTimeZone(sourceTimeZone);
if (truncateAt == Calendar.HOUR_OF_DAY) {
result.set(Calendar.HOUR_OF_DAY, source.get(Calendar.HOUR_OF_DAY));
result.set(Calendar.MONTH, source.get(Calendar.MONTH));
result.set(Calendar.DAY_OF_MONTH, source.get(Calendar.DAY_OF_MONTH));
result.set(Calendar.DST_OFFSET, source.get(Calendar.DST_OFFSET));
} else if (truncateAt == Calendar.DAY_OF_MONTH) {
result.set(Calendar.MONTH, source.get(Calendar.MONTH));
result.set(Calendar.DAY_OF_MONTH, source.get(Calendar.DAY_OF_MONTH));
// if (log.isDebugEnabled()) log.debug("result.get(Calendar.HOUR_OF_DAY): " + result.get(Calendar.HOUR_OF_DAY));
} else if (truncateAt == Calendar.MONTH) {
result.set(Calendar.MONTH, source.get(Calendar.MONTH));
} else if (truncateAt == Calendar.YEAR) { // NOPMD
// do nothing
} else { // NOPMD
throw new IllegalArgumentException("Unknown truncateAt");
}
return result.getTime();
}
示例8: getTimeZone
import java.util.Calendar; //导入方法依赖的package包/类
/**
* Gets the active time zone based on a Calendar argument
*/
public static TimeZone getTimeZone(Calendar cal) {
if (cal == null) {
return DEFAULT_ZONE;
}
return cal.getTimeZone();
}
示例9: getTimezoneOffset
import java.util.Calendar; //导入方法依赖的package包/类
public static int getTimezoneOffset() {
Calendar calendar = new GregorianCalendar();
TimeZone timeZone = calendar.getTimeZone();
return - (int) TimeUnit.MILLISECONDS.toMinutes(timeZone.getRawOffset()); // we negate the offset because thats the value which is provided by the browser as well
}
示例10: TxFragment
import java.util.Calendar; //导入方法依赖的package包/类
public TxFragment() {
super();
Calendar cal = Calendar.getInstance();
TimeZone tz = cal.getTimeZone(); //get the local time zone.
TS_FORMATTER.setTimeZone(tz);
}