本文整理了Java中java.time.Period.isZero()
方法的一些代码示例,展示了Period.isZero()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Period.isZero()
方法的具体详情如下:
包路径:java.time.Period
类名称:Period
方法名:isZero
[英]Checks if all three units of this period are zero.
A zero period has the value zero for the years, months and days units.
[中]检查这段时间的三个单位是否都为零。
零周期的年、月和日单位的值为零。
代码示例来源:origin: jdbi/jdbi
@Test
public void testTrivialPeriod() {
handle.execute("insert into intervals(id, foo) values(?, ?)", 4, Period.of(0, 0, 0));
Period p = handle.createQuery("select foo from intervals where id=?")
.bind(0, 4)
.mapTo(Period.class)
.findOnly();
assertThat(p.isZero());
}
代码示例来源:origin: com.jtransc/jtransc-rt
public String toString() {
if (isZero()) return "P0D";
String out = "P";
if (years != 0) out += years + "Y";
if (months != 0) out += months + "M";
if (days != 0) out += days + "D";
return out;
}
}
代码示例来源:origin: org.threeten/threeten-extra
/**
* Checks if all parts of this amount are zero.
* <p>
* This returns true if both {@link Period#isZero()} and {@link Duration#isZero()}
* return true.
*
* @return true if this period is zero-length
*/
public boolean isZero() {
return period.isZero() && duration.isZero();
}
代码示例来源:origin: org.jadira.usertype/usertype.core
/**
* Returns a string representation of the amount of time.
* @param value Period to convert to a String
* @return the amount of time in ISO8601 string format
*/
public String toString(Period value) {
final String str;
if (value.isZero()) {
str = "PT0S";
} else {
StringBuilder buf = new StringBuilder();
buf.append('P');
if (value.getYears() != 0) {
buf.append(value.getYears()).append('Y');
}
if (value.getMonths() != 0) {
buf.append(value.getMonths()).append('M');
}
if (value.getDays() != 0) {
buf.append(value.getDays()).append('D');
}
str = buf.toString();
}
return str;
}
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(lag.isZero() || lag.isNegative(), "Lag must be positive");
}
代码示例来源:origin: org.jadira.usertype/usertype.extended
/**
* Returns a string representation of the amount of time.
* @param value Period to convert to a String
* @return the amount of time in ISO8601 string format
*/
public String toString(Period value) {
final String str;
if (value.isZero()) {
str = "PT0S";
} else {
StringBuilder buf = new StringBuilder();
buf.append('P');
if (value.getYears() != 0) {
buf.append(value.getYears()).append('Y');
}
if (value.getMonths() != 0) {
buf.append(value.getMonths()).append('M');
}
if (value.getDays() != 0) {
buf.append(value.getDays()).append('D');
}
str = buf.toString();
}
return str;
}
}
代码示例来源:origin: zeebe-io/zeebe
private boolean isCalendarBased() {
return !getPeriod().isZero() || getDuration().compareTo(ACCURATE_DURATION_UPPER_BOUND) >= 0;
}
代码示例来源:origin: io.zeebe/zb-bpmn-model
private boolean isCalendarBased() {
return !getPeriod().isZero() || getDuration().compareTo(ACCURATE_DURATION_UPPER_BOUND) >= 0;
}
代码示例来源:origin: zeebe-io/zeebe
@Override
public String toString() {
if (period.isZero()) {
return duration.toString();
}
if (duration.isZero()) {
return period.toString();
}
return period.toString() + duration.toString().substring(1);
}
代码示例来源:origin: org.threeten/threeten-extra
/**
* Formats a period and duration to a string in ISO-8601 format.
* <p>
* To obtain the ISO-8601 format of a {@code Period} or {@code Duration}
* individually, simply call {@code toString()}.
* See also {@link PeriodDuration}.
*
* @param period the period to format
* @param duration the duration to format
* @return the ISO-8601 format for the period and duration
*/
public static String iso8601(Period period, Duration duration) {
Objects.requireNonNull(period, "period must not be null");
Objects.requireNonNull(duration, "duration must not be null");
if (period.isZero()) {
return duration.toString();
}
if (duration.isZero()) {
return period.toString();
}
return period.toString() + duration.toString().substring(1);
}
代码示例来源:origin: io.zeebe/zb-bpmn-model
@Override
public String toString() {
if (period.isZero()) {
return duration.toString();
}
if (duration.isZero()) {
return period.toString();
}
return period.toString() + duration.toString().substring(1);
}
代码示例来源:origin: OpenGamma/Strata
/**
* Creates a tenor.
*
* @param period the period to represent
* @param name the name
*/
private Tenor(Period period, String name) {
ArgChecker.notNull(period, "period");
ArgChecker.isFalse(period.isZero(), "Tenor period must not be zero");
ArgChecker.isFalse(period.isNegative(), "Tenor period must not be negative");
this.period = period;
this.name = name;
}
代码示例来源:origin: org.threeten/threeten-extra
/**
* Returns a string representation of the amount.
* This will be in the format 'PnYnMnDTnHnMnS', with sections omitted as necessary.
* An empty amount will return "PT0S".
*
* @return the period in ISO-8601 string format
*/
@Override
@ToString
public String toString() {
if (period.isZero()) {
return duration.toString();
}
if (duration.isZero()) {
return period.toString();
}
return period.toString() + duration.toString().substring(1);
}
代码示例来源:origin: OpenGamma/Strata
ArgChecker.isFalse(period.isZero(), "Frequency period must not be zero");
ArgChecker.isFalse(period.isNegative(), "Frequency period must not be negative");
this.period = period;
代码示例来源:origin: OpenGamma/Strata
/**
* Converts an FpML 'RelativeDateOffset' to a {@code DaysAdjustment}.
*
* @param baseEl the FpML adjustable date element
* @return the days adjustment
* @throws RuntimeException if unable to parse
*/
public DaysAdjustment parseRelativeDateOffsetDays(XmlElement baseEl) {
// FpML content: ('periodMultiplier', 'period', 'dayType?',
// 'businessDayConvention', 'BusinessCentersOrReference.model?'
// 'dateRelativeTo', 'adjustedDate')
// The 'dateRelativeTo' element is not used here
// The 'adjustedDate' element is ignored
Period period = parsePeriod(baseEl);
if (period.toTotalMonths() != 0) {
throw new FpmlParseException("Expected days-based period but found " + period);
}
Optional<XmlElement> dayTypeEl = baseEl.findChild("dayType");
boolean calendarDays = period.isZero() || (dayTypeEl.isPresent() && dayTypeEl.get().getContent().equals("Calendar"));
BusinessDayConvention fixingBdc = convertBusinessDayConvention(
baseEl.getChild("businessDayConvention").getContent());
HolidayCalendarId calendar = parseBusinessCenters(baseEl);
if (calendarDays) {
return DaysAdjustment.ofCalendarDays(
period.getDays(), BusinessDayAdjustment.of(fixingBdc, calendar));
} else {
return DaysAdjustment.ofBusinessDays(period.getDays(), calendar);
}
}
代码示例来源:origin: com.github.seratch/java-time-backport
if (excessDays != null && excessDays.isZero() == false && date != null && time != null) {
date = date.plus(excessDays);
excessDays = Period.ZERO;
代码示例来源:origin: OpenGamma/Strata
boolean fixingCalendarDays = period.isZero() ||
(dayTypeEl.isPresent() && dayTypeEl.get().getContent().equals("Calendar"));
if (fixingCalendarDays) {
代码示例来源:origin: OpenGamma/Strata
boolean calendarDays = period.isZero() || (dayTypeEl.isPresent() && dayTypeEl.get().getContent().equals("Calendar"));
BusinessDayAdjustment bda1 = parseBusinessDayAdjustments(baseEl);
BusinessDayAdjustment bda2 = baseEl.findChild("relativeDateAdjustments")
内容来源于网络,如有侵权,请联系作者删除!