本文整理匯總了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);
}