Java Code Examples for java.time.YearMonth#getYear()

The following examples show how to use java.time.YearMonth#getYear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YearMonthTypeDescriptor.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
@Override
public <X> X unwrap(YearMonth value, Class<X> type, WrapperOptions options) {
    if (value == null) {
        return null;
    }
    if (String.class.isAssignableFrom(type)) {
        return (X) toString(value);
    }
    if (Number.class.isAssignableFrom(type)) {
        Integer numericValue = (value.getYear() * 100) + value.getMonth().getValue();
        return (X) (numericValue);
    }
    if (Timestamp.class.isAssignableFrom(type)) {
        return (X) java.sql.Timestamp.valueOf(value.atDay(1).atStartOfDay());
    }
    if (Date.class.isAssignableFrom(type)) {
        return (X) java.sql.Date.valueOf(value.atDay(1));
    }
    throw unknownUnwrap(type);
}
 
Example 2
Source File: YearMonthHandle.java    From alibaba-rsocket-broker with Apache License 2.0 4 votes vote down vote up
public YearMonthHandle(YearMonth o) {
    this.year = o.getYear();
    this.month = o.getMonthValue();
}
 
Example 3
Source File: YearMonthHandle.java    From joyrpc with Apache License 2.0 4 votes vote down vote up
@Override
public void wrap(final YearMonth yearMonth) {
    this.year = yearMonth.getYear();
    this.month = yearMonth.getMonthValue();
}
 
Example 4
Source File: MySQLYearMonthIntegerTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
    return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
 
Example 5
Source File: PostgreSQLYearMonthIntegerConverterAutoApplyTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
    return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
 
Example 6
Source File: PostgreSQLYearMonthIntegerTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
    return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}