- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.YearMonth
类的一些代码示例,展示了YearMonth
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth
类的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
[英]A year-month in the ISO-8601 calendar system, such as 2007-12.
YearMonth is an immutable date-time object that represents the combination of a year and month. Any field that can be derived from a year and month, such as quarter-of-year, can be obtained.
This class does not store or represent a day, time or time-zone. For example, the value "October 2007" can be stored in a YearMonth.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
This class is immutable and thread-safe.
[中]ISO-8601日历系统中的一年一月,如2007-12。
YearMonth是一个不可变的日期时间对象,表示年和月的组合。可以获得任何可以从一年和一个月派生的字段,例如一年的季度。
此类不存储或表示日期、时间或时区。例如,值“2007年10月”可以存储在YearMonth中。
ISO-8601日历系统是当今世界大部分地区使用的现代民用日历系统。它相当于公历的前身,即今天的闰年规则一直适用。对于今天编写的大多数应用程序,ISO-8601规则完全适用。然而,任何使用历史日期并要求其准确的应用程序都会发现ISO-8601方法不合适。
####实施者规范
这个类是不可变的,是线程安全的。
代码示例来源:origin: hibernate/hibernate-orm
@Override
public YearMonth convertToEntityAttribute(Integer dbData) {
return YearMonth.of(dbData / 100, dbData % 100);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public YearMonth parse(String text, Locale locale) throws ParseException {
return YearMonth.parse(text);
}
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310
protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
SerializerProvider provider) throws IOException
{
g.writeNumber(value.getYear());
g.writeNumber(value.getMonthValue());
}
代码示例来源:origin: wildfly/wildfly
@Override
public void writeObject(ObjectOutput output, YearMonth value) throws IOException {
output.writeInt(value.getYear());
DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth());
}
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310
@Override
public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException
{
if (useTimestamp(provider)) {
g.writeStartArray();
_serializeAsArrayContents(value, g, provider);
g.writeEndArray();
return;
}
g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
}
代码示例来源:origin: OpenGamma/Strata
public void test_optionIdUnderlying_monthly() {
SecurityId test = EtdIdUtils.optionId(
ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34, YearMonth.of(2017, 9));
assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34-U201709"));
}
代码示例来源:origin: OpenGamma/Strata
@Test(dataProvider = "quarterly10th")
public void test_nextOrSameQuarterly10th(LocalDate base, LocalDate expect1, LocalDate expect2, LocalDate expect3) {
LocalDate date = base.plusDays(1);
while (!date.isAfter(expect1)) {
assertEquals(DateSequences.QUARTERLY_10TH.nextOrSame(date), expect1);
assertEquals(DateSequences.QUARTERLY_10TH.nthOrSame(date, 1), expect1);
assertEquals(DateSequences.QUARTERLY_10TH.nthOrSame(date, 2), expect2);
assertEquals(DateSequences.QUARTERLY_10TH.nthOrSame(date, 3), expect3);
date = date.plusDays(1);
}
assertEquals(DateSequences.QUARTERLY_10TH.dateMatching(YearMonth.from(date)), expect1);
}
代码示例来源:origin: OpenGamma/Strata
public void test_metadata_end() {
IborFutureCurveNode node = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL);
LocalDate date = LocalDate.of(2015, 10, 20);
LocalDate referenceDate = TEMPLATE.calculateReferenceDateFromTradeDate(date, REF_DATA);
LocalDate maturityDate = TEMPLATE.getIndex().calculateMaturityFromEffective(referenceDate, REF_DATA);
ParameterMetadata metadata = node.metadata(date, REF_DATA);
assertEquals(metadata.getLabel(), LABEL);
assertTrue(metadata instanceof YearMonthDateParameterMetadata);
assertEquals(((YearMonthDateParameterMetadata) metadata).getDate(), maturityDate);
assertEquals(((YearMonthDateParameterMetadata) metadata).getYearMonth(), YearMonth.from(referenceDate));
}
代码示例来源:origin: OpenGamma/Strata
public void test_QUARTERLY_IMM() {
DateSequence test = DateSequences.QUARTERLY_IMM;
assertEquals(test.getName(), "Quarterly-IMM");
assertEquals(test.toString(), "Quarterly-IMM");
assertEquals(test.dateMatching(YearMonth.of(2013, 3)), LocalDate.of(2013, 3, 20));
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
return GregorianCalendar.from(ot.atDate(LocalDate.ofEpochDay(0)).atZoneSameInstant(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {
return GregorianCalendar.from(ot.atDate(LocalDate.ofEpochDay(0)).atZoneSameInstant(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {
return GregorianCalendar.from(ot.atDate(LocalDate.ofEpochDay(0)).atZoneSameInstant(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {
final Year y = Year.from(ta);
final MonthDay md = MonthDay.from(ta);
final OffsetTime ot = OffsetTime.from(ta);
return GregorianCalendar.from(ot.atDate(y.atMonthDay(md)).atZoneSameInstant(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {
final Year y = Year.from(ta);
final MonthDay md = MonthDay.from(ta);
final OffsetTime ot = OffsetTime.from(ta);
final YearMonth ym = YearMonth.parse(str);
return GregorianCalendar.from(ym.atDay(1).atStartOfDay(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {
代码示例来源:origin: OpenGamma/Strata
public void test_metadata_last_fixing() {
IborFutureCurveNode node =
IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL).withDate(CurveNodeDate.LAST_FIXING);
ImmutableMarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, 0.0d).build();
IborFutureTrade trade = node.trade(1d, marketData, REF_DATA);
LocalDate fixingDate = trade.getProduct().getFixingDate();
DatedParameterMetadata metadata = node.metadata(VAL_DATE, REF_DATA);
assertEquals(metadata.getDate(), fixingDate);
LocalDate referenceDate = TEMPLATE.calculateReferenceDateFromTradeDate(VAL_DATE, REF_DATA);
assertEquals(((YearMonthDateParameterMetadata) metadata).getYearMonth(), YearMonth.from(referenceDate));
}
代码示例来源:origin: apache/tinkerpop
addExtendedEntry(LocalDate.of(2016, 1, 1), "LocalDate", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(LocalDateTime.of(2016, 1, 1, 12, 30), "LocalDateTime", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(LocalTime.of(12, 30, 45), "LocalTime", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(Period.of(1, 6, 15), "Period", "The following example is a `Period` of one year, six months and fifteen days.", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(new Short("100"), "Short", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(Year.of(2016), "Year", "The following example is of the `Year` \"2016\".", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(YearMonth.of(2016, 6), "YearMonth", "The following example is a `YearMonth` of \"June 2016\"", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(ZonedDateTime.of(2016, 12, 23, 12, 12, 24, 36, ZoneId.of("GMT+2")), "ZonedDateTime", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
addExtendedEntry(ZoneOffset.ofHoursMinutesSeconds(3, 6, 9), "ZoneOffset", "The following example is a `ZoneOffset` of three hours, six minutes, and nine seconds.", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
代码示例来源:origin: jfoenixadmin/JFoenix
int firstOfMonthIndex = selectedYearMonth.get().atDay(1).getDayOfWeek().getValue() - firstDayOfWeek;
firstOfMonthIndex += firstOfMonthIndex < 0 ? daysPerWeek : 0;
YearMonth currentYearMonth = selectedYearMonth.get();
daysInCurMonth = currentYearMonth.lengthOfMonth();
LocalDate date = currentYearMonth.atDay(dayIndex);
dayCellDates[i] = date;
if (date.equals(LocalDate.now())) {
dayCell.setTextFill(this.datePicker.getDefaultColor());
dayCell.getStyleClass().add("today");
代码示例来源:origin: wildfly/wildfly
assertTrue(immutability.test(Duration.ZERO));
assertTrue(immutability.test(Instant.now()));
assertTrue(immutability.test(LocalDate.now()));
assertTrue(immutability.test(LocalDateTime.now()));
assertTrue(immutability.test(LocalTime.now()));
assertTrue(immutability.test(ValueRange.of(0L, 10L)));
assertTrue(immutability.test(WeekFields.ISO));
assertTrue(immutability.test(Year.now()));
assertTrue(immutability.test(YearMonth.now()));
assertTrue(immutability.test(ZoneOffset.UTC));
assertTrue(immutability.test(ZoneRules.of(ZoneOffset.UTC).nextTransition(Instant.now())));
代码示例来源:origin: jfoenixadmin/JFoenix
void clearFocus() {
LocalDate focusDate = datePicker.getValue();
if (focusDate == null) {
focusDate = LocalDate.now();
}
if (YearMonth.from(focusDate).equals(selectedYearMonth.get())) {
goToDate(focusDate, true);
}
}
代码示例来源:origin: stackoverflow.com
// Code for your method.
YearMonth yearMonth = year.atMonth ( month ); // Instantiate a YearMonth from a Year and a Month.
LocalDate localDate = yearMonth.atDay ( 1 ); // First day of month.
ZoneId zoneId = ZoneId.systemDefault (); // Or… ZoneId.of("America/Montreal");
ZonedDateTime zdt = localDate.atStartOfDay ( zoneId );
long millis = zdt.toInstant ().toEpochMilli ();
代码示例来源:origin: jfoenixadmin/JFoenix
protected void updateMonthYearPane() {
// update date labels
YearMonth yearMonth = selectedYearMonth.get();
LocalDate value = datePicker.getValue();
value = value == null ? LocalDate.now() : value;
selectedDateLabel.setText(DateTimeFormatter.ofPattern("EEE, MMM dd").format(value));
selectedYearLabel.setText(formatYear(yearMonth));
monthYearLabel.setText(formatMonth(yearMonth) + " " + formatYear(yearMonth));
Chronology chrono = datePicker.getChronology();
LocalDate firstDayOfMonth = yearMonth.atDay(1);
backMonthButton.setDisable(!isValidDate(chrono, firstDayOfMonth, -1, DAYS));
forwardMonthButton.setDisable(!isValidDate(chrono, firstDayOfMonth, +1, MONTHS));
}
代码示例来源:origin: jfoenixadmin/JFoenix
selectedYearMonth.set((date != null) ? YearMonth.from(date) : YearMonth.now());
selectedYearMonth.addListener((observable, oldValue, newValue) -> updateValues());
goToDate(LocalDate.now(), true);
event.consume();
break;
代码示例来源:origin: zsoltherpai/fluent-jdbc
private static void javaTime(Map<Class, ParamSetter> ss) {
reg(ss, Instant.class, (param, ps, i) -> ps.setTimestamp(i, timestamp(param)));
reg(ss, OffsetDateTime.class, (param, ps, i) -> ps.setTimestamp(i, timestamp(param.toInstant())));
reg(ss, ZonedDateTime.class, (param, ps, i) -> ps.setTimestamp(i, timestamp(param.toInstant())));
reg(ss, LocalDate.class, (param, ps, i) -> ps.setDate(i, java.sql.Date.valueOf(param)));
reg(ss, LocalTime.class, (param, ps, i) -> ps.setTime(i, java.sql.Time.valueOf(param)));
reg(ss, LocalDateTime.class, (param, ps, i) -> ps.setTimestamp(i, java.sql.Timestamp.valueOf(param)));
reg(ss, Year.class, (param, ps, i) -> ps.setDate(i, java.sql.Date.valueOf(LocalDate.of(param.getValue(), Month.JANUARY, 1))));
reg(ss, YearMonth.class, (param, ps, i) -> ps.setDate(i, java.sql.Date.valueOf(LocalDate.of(param.getYear(), param.getMonth(), 1))));
}
代码示例来源:origin: ebean-orm/ebean
protected LocalDate toLocalDate(YearMonth yearMonth) {
return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
}
此 map-reduce 用于计算“Hadoop:权威指南”中的示例每年和每月的平均温度 输出应该是 年[TAB]月[TAB]平均_温度 由于键(年+月)已经合并,是否可以使用 substring()
我想解析两个单独的字符串 "1982"和"SEP"进入java.time.YearMonth对象。 java.time.YearMonth.parse("1978 SEP", java.time.fo
在.Net Framework中,我们常用的时间类型是DateTime。直到.Net6微软加入了两个新的时间类型:DateOnly和TimeOnly,才弥补了之前的不足。 DateOnly :
本文整理了Java中java.time.YearMonth.with()方法的一些代码示例,展示了YearMonth.with()的具体用法。这些代码示例主要来源于Github/Stackoverfl
本文整理了Java中java.time.YearMonth.until()方法的一些代码示例,展示了YearMonth.until()的具体用法。这些代码示例主要来源于Github/Stackover
本文整理了Java中java.time.YearMonth.from()方法的一些代码示例,展示了YearMonth.from()的具体用法。这些代码示例主要来源于Github/Stackoverfl
本文整理了Java中java.time.YearMonth.of()方法的一些代码示例,展示了YearMonth.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/M
我正在使用 joda.time 的 YearMonth 对象,并希望在此对象中获取月份日期的最后一天。 yearMonth.monthOfYear().getMaximumValue(); //ret
我想找到等于或晚于当前 YearMonth 的月份 final YearMonth yearMonth = YearMonth.of(2020, 8); final boolean after = y
如何在实体中使用 YearMonth?我已经看到很多关于转换器的堆栈溢出答案?这仍然需要吗?如果需要的话如何? @Basic(optional = false) @NotNull @Column(na
我在解析代表年份和月份的特殊字符串时遇到问题,偏移量如下:2014-08+03:00 . 所需的输出是 YearMonth . 我已经测试过创建自定义 DateTimeFormatter有各种模式,但
本文整理了Java中java.time.YearMonth.()方法的一些代码示例,展示了YearMonth.()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven
本文整理了Java中java.time.YearMonth.compareTo()方法的一些代码示例,展示了YearMonth.compareTo()的具体用法。这些代码示例主要来源于Github/S
本文整理了Java中java.time.YearMonth.lengthOfMonth()方法的一些代码示例,展示了YearMonth.lengthOfMonth()的具体用法。这些代码示例主要来源于
本文整理了Java中java.time.YearMonth.minusMonths()方法的一些代码示例,展示了YearMonth.minusMonths()的具体用法。这些代码示例主要来源于Gith
本文整理了Java中java.time.YearMonth.now()方法的一些代码示例,展示了YearMonth.now()的具体用法。这些代码示例主要来源于Github/Stackoverflow
本文整理了Java中java.time.YearMonth.isBefore()方法的一些代码示例,展示了YearMonth.isBefore()的具体用法。这些代码示例主要来源于Github/Sta
本文整理了Java中java.time.YearMonth.getMonth()方法的一些代码示例,展示了YearMonth.getMonth()的具体用法。这些代码示例主要来源于Github/Sta
本文整理了Java中java.time.YearMonth.format()方法的一些代码示例,展示了YearMonth.format()的具体用法。这些代码示例主要来源于Github/Stackov
本文整理了Java中java.time.YearMonth.plus()方法的一些代码示例,展示了YearMonth.plus()的具体用法。这些代码示例主要来源于Github/Stackoverfl
我是一名优秀的程序员,十分优秀!