本文整理了Java中org.threeten.bp.Year.of()
方法的一些代码示例,展示了Year.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Year.of()
方法的具体详情如下:
包路径:org.threeten.bp.Year
类名称:Year
方法名:of
[英]Obtains an instance of Year.
This method accepts a year value from the proleptic ISO calendar system.
The year 2AD/CE is represented by 2.
The year 1AD/CE is represented by 1.
The year 1BC/BCE is represented by 0.
The year 2BC/BCE is represented by -1.
[中]获得一个年的实例。
此方法接受proleptic ISO日历系统中的年份值。
公元2AD/CE年用2表示。
公元1AD/CE年用1表示。
公元前1年/公元前1年用0表示。
公元前2年/公元前2年用-1表示。
代码示例来源:origin: ThreeTen/threetenbp
static Year readExternal(DataInput in) throws IOException {
return Year.of(in.readInt());
}
代码示例来源:origin: org.threeten/threetenbp
static Year readExternal(DataInput in) throws IOException {
return Year.of(in.readInt());
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this year with the specified number of years added.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param yearsToAdd the years to add, may be negative
* @return a {@code Year} based on this year with the period added, not null
* @throws DateTimeException if the result exceeds the supported year range
*/
public Year plusYears(long yearsToAdd) {
if (yearsToAdd == 0) {
return this;
}
return of(YEAR.checkValidIntValue(year + yearsToAdd)); // overflow safe
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this year with the specified number of years added.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param yearsToAdd the years to add, may be negative
* @return a {@code Year} based on this year with the period added, not null
* @throws DateTimeException if the result exceeds the supported year range
*/
public Year plusYears(long yearsToAdd) {
if (yearsToAdd == 0) {
return this;
}
return of(YEAR.checkValidIntValue(year + yearsToAdd)); // overflow safe
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains the current year from the specified clock.
* <p>
* This will query the specified clock to obtain the current year.
* Using this method allows the use of an alternate clock for testing.
* The alternate clock may be introduced using {@link Clock dependency injection}.
*
* @param clock the clock to use, not null
* @return the current year, not null
*/
public static Year now(Clock clock) {
final LocalDate now = LocalDate.now(clock); // called once
return Year.of(now.getYear());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains the current year from the specified clock.
* <p>
* This will query the specified clock to obtain the current year.
* Using this method allows the use of an alternate clock for testing.
* The alternate clock may be introduced using {@link Clock dependency injection}.
*
* @param clock the clock to use, not null
* @return the current year, not null
*/
public static Year now(Clock clock) {
final LocalDate now = LocalDate.now(clock); // called once
return Year.of(now.getYear());
}
代码示例来源:origin: ThreeTen/threetenbp
f.checkValidValue(newValue);
switch (f) {
case YEAR_OF_ERA: return Year.of((int) (year < 1 ? 1 - newValue : newValue));
case YEAR: return Year.of((int) newValue);
case ERA: return (getLong(ERA) == newValue ? this : Year.of(1 - year));
代码示例来源:origin: org.threeten/threetenbp
f.checkValidValue(newValue);
switch (f) {
case YEAR_OF_ERA: return Year.of((int) (year < 1 ? 1 - newValue : newValue));
case YEAR: return Year.of((int) newValue);
case ERA: return (getLong(ERA) == newValue ? this : Year.of(1 - year));
代码示例来源:origin: org.threeten/threetenbp
zone.year = Year.of(Integer.parseInt(st.nextToken()));
if (st.hasMoreTokens()) {
parseMonthDayTime(st, zone);
代码示例来源:origin: ThreeTen/threetenbp
zone.year = Year.of(Integer.parseInt(st.nextToken()));
if (st.hasMoreTokens()) {
parseMonthDayTime(st, zone);
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public Year deserialize(JsonParser parser, DeserializationContext context) throws IOException
{
JsonToken t = parser.getCurrentToken();
if (t == JsonToken.VALUE_STRING) {
String string = parser.getValueAsString().trim();
try {
if (_formatter == null) {
return Year.parse(string);
}
return Year.parse(string, _formatter);
} catch (DateTimeException e) {
_rethrowDateTimeException(parser, context, e, string);
}
}
if (t == JsonToken.VALUE_NUMBER_INT) {
return Year.of(parser.getIntValue());
}
if (t == JsonToken.VALUE_EMBEDDED_OBJECT) {
return (Year) parser.getEmbeddedObject();
}
throw context.mappingException("Unexpected token (%s), expected VALUE_STRING or VALUE_NUMBER_INT",
parser.getCurrentToken());
}
}
代码示例来源:origin: ThreeTen/threetenbp
temporal = LocalDate.from(temporal);
return of(temporal.get(YEAR));
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain Year from TemporalAccessor: " +
代码示例来源:origin: org.threeten/threetenbp
temporal = LocalDate.from(temporal);
return of(temporal.get(YEAR));
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain Year from TemporalAccessor: " +
内容来源于网络,如有侵权,请联系作者删除!