本文整理了Java中java.time.Period.getDays()
方法的一些代码示例,展示了Period.getDays()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Period.getDays()
方法的具体详情如下:
包路径:java.time.Period
类名称:Period
方法名:getDays
[英]Gets the amount of days of this period.
This returns the days unit.
[中]获取此期间的天数。
这将返回天数单位。
代码示例来源:origin: neo4j/neo4j
public static DurationValue duration( Period value )
{
requireNonNull( value, "Period" );
return newDuration( value.toTotalMonths(), value.getDays(), 0, 0 );
}
代码示例来源:origin: wildfly/wildfly
@Override
public void writeObject(ObjectOutput output, Period period) throws IOException {
output.writeInt(period.getYears());
output.writeInt(period.getMonths());
output.writeInt(period.getDays());
}
代码示例来源:origin: jdbi/jdbi
@Override
public Argument build(Period period, ConfigRegistry config) {
PGInterval interval = new PGInterval(period.getYears(), period.getMonths(), period.getDays(), 0, 0, 0);
return ObjectArgument.of(interval, Types.OTHER);
}
}
代码示例来源:origin: pholser/junit-quickcheck
private BigInteger toBigInteger(Period period) {
return BigInteger.valueOf(period.getYears())
.multiply(TWELVE)
.add(BigInteger.valueOf(period.getMonths()))
.multiply(THIRTY_ONE)
.add(BigInteger.valueOf(period.getDays()));
}
代码示例来源:origin: apache/tinkerpop
@Override
protected ByteBuf writeValue(final Period value, final ByteBufAllocator allocator, final GraphBinaryWriter context) throws SerializationException {
return allocator.buffer(12).writeInt(value.getYears()).writeInt(value.getMonths()).writeInt(value.getDays());
}
}
代码示例来源:origin: pholser/junit-quickcheck
private static BigInteger toBigInteger(Period period) {
return BigInteger.valueOf(period.getYears())
.multiply(TWELVE)
.add(BigInteger.valueOf(period.getMonths()))
.multiply(THIRTY_ONE)
.add(BigInteger.valueOf(period.getDays()));
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Period period) {
output.writeInt(period.getYears());
output.writeInt(period.getMonths());
output.writeInt(period.getDays());
}
代码示例来源:origin: OpenGamma/Strata
/**
* Checks if the periodic frequency is week-based.
* <p>
* A week-based frequency consists of an integral number of weeks.
* There must be no day, month or year element.
*
* @return true if this is week-based
*/
public boolean isWeekBased() {
return period.toTotalMonths() == 0 && period.getDays() % 7 == 0;
}
代码示例来源:origin: OpenGamma/Strata
/**
* Checks if the periodic frequency is annual.
* <p>
* An annual frequency consists of 12 months.
* There must be no day or week element.
*
* @return true if this is annual
*/
public boolean isAnnual() {
return period.toTotalMonths() == 12 && period.getDays() == 0;
}
代码示例来源:origin: OpenGamma/Strata
/**
* Checks if the tenor is week-based.
* <p>
* A week-based tenor consists of an integral number of weeks.
* There must be no day, month or year element.
*
* @return true if this is week-based
*/
public boolean isWeekBased() {
return period.toTotalMonths() == 0 && period.getDays() % 7 == 0;
}
代码示例来源:origin: OpenGamma/Strata
/**
* Checks if the tenor is month-based.
* <p>
* A month-based tenor consists of an integral number of months.
* Any year-based tenor is also counted as month-based.
* There must be no day or week element.
*
* @return true if this is month-based
*/
public boolean isMonthBased() {
return period.toTotalMonths() > 0 && period.getDays() == 0;
}
代码示例来源:origin: org.jboss.eap/wildfly-clustering-marshalling-spi
@Override
public void writeObject(ObjectOutput output, Period period) throws IOException {
output.writeInt(period.getYears());
output.writeInt(period.getMonths());
output.writeInt(period.getDays());
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
if (additionConvention.isMonthBased() && period.getDays() != 0) {
throw new IllegalArgumentException("Period must not contain days when addition convention is month-based");
}
}
代码示例来源:origin: OpenGamma/Strata
/**
* Checks if the periodic frequency is month-based.
* <p>
* A month-based frequency consists of an integral number of months.
* Any year-based frequency is also counted as month-based.
* There must be no day or week element.
*
* @return true if this is month-based
*/
public boolean isMonthBased() {
return period.toTotalMonths() > 0 && period.getDays() == 0 && isTerm() == false;
}
代码示例来源:origin: com.guestful.module/guestful.module.jsr310-extensions
public static Duration toDuration(Period p) {
if (p.getMonths() > 0) throw new IllegalArgumentException(p.toString());
if (p.getYears() > 0) throw new IllegalArgumentException(p.toString());
return Duration.ofDays(p.getDays());
}
代码示例来源:origin: com.esotericsoftware/kryo
public void write (Kryo kryo, Output out, Period obj) {
out.writeInt(obj.getYears(), true);
out.writeInt(obj.getMonths(), true);
out.writeInt(obj.getDays(), true);
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Period period) {
output.writeInt(period.getYears());
output.writeInt(period.getMonths());
output.writeInt(period.getDays());
}
代码示例来源:origin: net.time4j/time4j-core
@Override
public Duration<CalendarUnit> translate(Period source) {
try {
Duration<CalendarUnit> duration =
Duration.ofCalendarUnits(source.getYears(), source.getMonths(), source.getDays());
return duration.with(Duration.STD_CALENDAR_PERIOD);
} catch (RuntimeException ex) {
throw new ChronoException("Cannot convert period: " + source, ex);
}
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void write (Kryo kryo, Output out, Period obj) {
out.writeInt(obj.getYears(), true);
out.writeInt(obj.getMonths(), true);
out.writeInt(obj.getDays(), true);
}
代码示例来源:origin: io.reactiverse/reactive-pg-client
private static void binaryEncodeINTERVAL(Interval interval, ByteBuf buff) {
Duration duration = Duration
.ofHours(interval.getHours())
.plusMinutes(interval.getMinutes())
.plusSeconds(interval.getSeconds())
.plus(interval.getMicroseconds(), ChronoUnit.MICROS);
// days won't be changed
Period monthYear = Period.of(interval.getYears(), interval.getMonths(), interval.getDays()).normalized();
binaryEncodeINT8(NANOSECONDS.toMicros(duration.toNanos()), buff);
binaryEncodeINT4(monthYear.getDays(), buff);
binaryEncodeINT4((int) monthYear.toTotalMonths(), buff);
}
内容来源于网络,如有侵权,请联系作者删除!