本文整理了Java中java.time.YearMonth.getMonth()
方法的一些代码示例,展示了YearMonth.getMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.getMonth()
方法的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
方法名:getMonth
[英]Gets the month-of-year field using the Month enum.
This method returns the enum Month for the month. This avoids confusion as to what int values mean. If you need access to the primitive int value then the enum provides the Month#getValue().
[中]使用月份枚举获取“月份”字段。
此方法返回当月的枚举月份。这避免了对int值的含义的混淆。如果需要访问原语int值,则枚举提供月#getValue()。
代码示例来源: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: hibernate/hibernate-orm
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
代码示例来源:origin: ebean-orm/ebean
protected LocalDate toLocalDate(YearMonth yearMonth) {
return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
}
代码示例来源:origin: jfoenixadmin/JFoenix
if (dateCell == null || !(dayCellDate(dateCell).getMonth() == yearMonth.getMonth())) {
dateCell = findDayCellOfDate(yearMonth.atDay(1));
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
for (int i = 5; i >= 0; i--) {
YearMonth date = YearMonth.now().minusMonths(i);
String monthName = date.getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH);
System.out.println(monthName + "(" + date.getYear() + ")");
}
}
代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker
@Override
public void integerTextFieldNumberChanged(JIntegerTextField source, int newValue) {
YearMonth newYearMonth = YearMonth.of(newValue, displayedYearMonth.getMonth());
drawCalendar(newYearMonth);
}
};
代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker
@Override
public void actionPerformed(ActionEvent e) {
String chosenMenuText = ((JMenuItem) e.getSource()).getText();
int chosenYear = Integer.parseInt(chosenMenuText);
drawCalendar(chosenYear, displayedYearMonth.getMonth());
}
}));
代码示例来源:origin: org.kie/kie-dmn-feel
private LocalDate getLocalDateFromYearAndMonth(final YearMonth yearMonth) {
return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
}
}
代码示例来源:origin: io.ebean/ebean
protected LocalDate toLocalDate(YearMonth yearMonth) {
return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
}
代码示例来源:origin: org.avaje.ebean/ebean
protected LocalDate toLocalDate(YearMonth yearMonth) {
return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns the length of the month, taking account of the year.
* <p>
* This returns the length of the month in days.
* For example, a date in January would return 31.
*
* @return the length of the month in days, from 28 to 31
*/
public int lengthOfMonth() {
return getMonth().length(isLeapYear());
}
代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker
/**
* getLastDayOfMonth, This returns the last day of the month for the specified year and month.
*
* Implementation notes: As of this writing, the below implementation is verified to work
* correctly for negative years, as those years are to defined in the iso 8601 your format that
* is used by java.time.YearMonth. This functionality can be tested by by checking to see if to
* see if the year "-0004" is correctly displayed as a leap year. Leap years have 29 days in
* February. There should be 29 days in the month of "February 1, -0004".
*/
private int getLastDayOfMonth(YearMonth yearMonth) {
LocalDate firstDayOfMonth = LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
int lastDayOfMonth = firstDayOfMonth.lengthOfMonth();
return lastDayOfMonth;
}
代码示例来源:origin: stackoverflow.com
YearMonth ym = ymStart;
do {
int daysInMonth = ym.lengthOfMonth ();
String monthName = ym.getMonth ().getDisplayName ( TextStyle.FULL , Locale.CANADA_FRENCH );
System.out.println ( ym + " : " + daysInMonth + " jours en " + monthName );
// Prepare for next loop.
ym = ym.plusMonths ( 1 );
} while ( ym.isBefore ( ymStop ) );
代码示例来源:origin: org.jboss.eap/wildfly-clustering-marshalling-spi
@Override
public void writeObject(ObjectOutput output, YearMonth value) throws IOException {
output.writeInt(value.getYear());
DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth());
}
代码示例来源: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: org.wildfly/wildfly-clustering-marshalling-spi
@Override
public void writeObject(ObjectOutput output, YearMonth value) throws IOException {
output.writeInt(value.getYear());
DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth());
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
代码示例来源:origin: OpenGamma/Strata
private static DoubleArray seasonalityCompounded(
LocalDate valDate, YearMonth fixingMonth, DoubleArray seasonality,
DoubleBinaryOperator adjustmentFunction) {
double nbMonths = YearMonth.from(valDate).until(fixingMonth, MONTHS);
double[] seasonalityCompoundedArray = new double[12];
int lastMonthIndex = fixingMonth.getMonth().getValue() - 2;
seasonalityCompoundedArray[(int) ((nbMonths + 12 + 1) % 12)] =
seasonality.get((lastMonthIndex + 1) % 12);
for (int i = 1; i < 12; i++) {
int j = (int) ((nbMonths + 12 + 1 + i) % 12);
seasonalityCompoundedArray[j] = adjustmentFunction.applyAsDouble(
seasonalityCompoundedArray[(j - 1 + 12) % 12], seasonality.get((lastMonthIndex + 1 + i) % 12));
}
return DoubleArray.ofUnsafe(seasonalityCompoundedArray);
}
内容来源于网络,如有侵权,请联系作者删除!