當前位置: 首頁>>代碼示例>>Java>>正文


Java Calendar.getTimeZone方法代碼示例

本文整理匯總了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));
        }
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:FastDateFormat.java

示例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));
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:14,代碼來源:FastDatePrinter.java

示例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());
  }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:12,代碼來源:GetCurrentTimeZone.java

示例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);
}
 
開發者ID:m2049r,項目名稱:xmrwallet,代碼行數:13,代碼來源:TransactionInfoAdapter.java

示例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);
}
 
開發者ID:m2049r,項目名稱:xmrwallet,代碼行數:9,代碼來源:WalletInfoAdapter.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:DatatypeConverterImpl.java

示例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();
  }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:StatisticsUtils.java

示例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();
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:10,代碼來源:DateTimeUtils.java

示例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 
}
 
開發者ID:yacy,項目名稱:yacy_grid_mcp,代碼行數:6,代碼來源:DateParser.java

示例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);
}
 
開發者ID:m2049r,項目名稱:xmrwallet,代碼行數:7,代碼來源:TxFragment.java


注:本文中的java.util.Calendar.getTimeZone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。