作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.opennms.core.time.ZonedDateTimeBuilder.getBestYearForMonth()
方法的一些代码示例,展示了ZonedDateTimeBuilder.getBestYearForMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTimeBuilder.getBestYearForMonth()
方法的具体详情如下:
包路径:org.opennms.core.time.ZonedDateTimeBuilder
类名称: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;
}
}
本文整理了Java中org.opennms.core.time.ZonedDateTimeBuilder.getBestYearForMonth()方法的一些代码示例,展示了ZonedDateTime
我是一名优秀的程序员,十分优秀!