gpt4 book ai didi

org.opennms.core.time.ZonedDateTimeBuilder.getBestYearForMonth()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 19:20:31 27 4
gpt4 key购买 nike

本文整理了Java中org.opennms.core.time.ZonedDateTimeBuilder.getBestYearForMonth()方法的一些代码示例,展示了ZonedDateTimeBuilder.getBestYearForMonth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTimeBuilder.getBestYearForMonth()方法的具体详情如下:
包路径:org.opennms.core.time.ZonedDateTimeBuilder
类名称:ZonedDateTimeBuilder
方法名:getBestYearForMonth

ZonedDateTimeBuilder.getBestYearForMonth介绍

暂无

代码示例

代码示例来源:origin: OpenNMS/opennms

/**
 * <p>If some fields have not been set,
 * intelligently set them so that we generate a observed 
 * datestamp that is less than or slightly greater than 
 * {@link System#currentTimeMillis()} (due to clock skew). 
 * For instance, around midnight on Dec 31, 2017, we do not 
 * want to generate datestamps of Dec 31, 2018 at the instant 
 * that {@link LocalDateTime#now()} starts returning a 
 * January 1, 2018 datestamp.</p>
 * 
 * @return
 */
protected int getBestYear() {
  if (m_year == null) {
    return getBestYearForMonth(m_month);
  } else {
    return m_year;
  }
}

代码示例来源:origin: OpenNMS/opennms

protected Date parseDate(final String dateString) {
  try {
    // Date pattern has been created and checked inside if loop instead of 
    // parsing date inside the exception class.
    if (dateString.matches(datePattern)) {
      final DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
      adjustTimeZone(df);
      return df.parse(dateString);
    } else {
      final DateFormat df = new SimpleDateFormat("MMM dd HH:mm:ss", Locale.ROOT);
      adjustTimeZone(df);
      // 2012-03-14 Ben: Ugh, what's a non-lame way of forcing it to parse to "this year"?
      Date date = df.parse(dateString);
      final Calendar c = df.getCalendar();
      c.setTime(date);
      // Add 1 to the month value because Calendar.MONTH is zero-based and
      // java.time.Month values are 1-based
      c.set(Calendar.YEAR, ZonedDateTimeBuilder.getBestYearForMonth(c.get(Calendar.MONTH) + 1));
      return c.getTime();
    }
  } catch (final Exception e) {
    LOG.debug("Unable to parse date '{}'", dateString, e);
    return null;
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com