java.time.Period.toString()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中java.time.Period.toString()方法的一些代码示例,展示了Period.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Period.toString()方法的具体详情如下:
包路径:java.time.Period
类名称:Period
方法名:toString

Period.toString介绍

[英]Outputs this period as a String, such as P6Y3M1D.

The output will be in the ISO-8601 period format. A zero period will be represented as zero days, 'P0D'.
[中]将此句点作为字符串输出,例如P6Y3M1D。
输出将采用ISO-8601周期格式。零期将表示为零天,“P0D”。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public String print(Period object, Locale locale) {
  return object.toString();
}

代码示例来源:origin: org.springframework/spring-context

@Override
public String print(Period object, Locale locale) {
  return object.toString();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public String convertToDatabaseColumn(Period attribute) {
  return attribute.toString();
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
  public byte[] convert(Period source) {
    return fromString(source.toString());
  }
}

代码示例来源:origin: ebean-orm/ebean

@Override
public String formatValue(Period v) {
 return v.toString();
}

代码示例来源:origin: ebean-orm/ebean

@Override
public String convertToDbString(Period beanValue) {
 return beanValue.toString();
}

代码示例来源:origin: OpenGamma/Strata

/**
 * Creates a periodic frequency.
 *
 * @param period  the period to represent
 */
private Frequency(Period period) {
 this(period, period.toString());
}

代码示例来源:origin: javers/javers

@Override
public String serialize(Period sourceValue) {
  return sourceValue.toString();
}

代码示例来源:origin: org.springframework.data/spring-data-couchbase

@Override
  public String convert(Period period) {
    return period.toString();
  }
}

代码示例来源:origin: net.dongliu/gson-java8-datatype

@Override
public void write(JsonWriter out, Period period) throws IOException {
  if (period == null) {
    out.nullValue();
    return;
  }
  out.value(period.toString());
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
  public byte[] convert(Period source) {
    return fromString(source.toString());
  }
}

代码示例来源:origin: dev.rico/rico-remoting-common

@Override
  public String convertToRemoting(final Period value) throws ValueConverterException{
    if(value == null) {
      return null;
    }
    try {
      return value.toString();
    } catch (Exception e) {
      throw new ValueConverterException("Can not convert from Periode", e);
    }
  }
}

代码示例来源:origin: OpenGamma/Strata

public static String[] dscIdValues(Period[] dscOisTenors) {
 String[] dscIdValues = new String[dscOisTenors.length];
 for (int i = 0; i < dscOisTenors.length; i++) {
  dscIdValues[i] = "OIS" + dscOisTenors[i].toString();
 }
 return dscIdValues;
}

代码示例来源:origin: org.eclipse/yasson

@Override
  protected void serialize(Period obj, JsonGenerator generator, Marshaller marshaller) {
    generator.write(obj.toString());
  }
}

代码示例来源:origin: jtransc/jtransc

static public void main(String[] args) {
    System.out.println("PeriodTest.main:");
    System.out.println(Period.ofDays(0).toString());
    System.out.println(Period.ofDays(1).toString());
    System.out.println(Period.ofDays(1).plusDays(40).toString());
    System.out.println(Period.parse(Period.ofDays(1).toString()));
  }
}

代码示例来源: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: 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: 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: com.guestful.module/guestful.module.json-serializer

private static Duration toDuration(Period p) {
  if (p.getMonths() > 0) throw new JsonException("Unable to serialize period: " + p.toString());
  if (p.getYears() > 0) throw new JsonException("Unable to serialize period: " + p.toString());
  return Duration.ofDays(p.getDays());
}

代码示例来源:origin: OpenGamma/Strata

@Override
public DatedParameterMetadata metadata(LocalDate valuationDate, ReferenceData refData) {
 return LabelDateParameterMetadata.of(
   HolidayCalendars.SAT_SUN.nextOrSame(valuationDate.plus(periodToEnd)), periodToEnd.toString());
}

相关文章