当前位置: 首页>>代码示例>>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;未经允许,请勿转载。