Java Code Examples for java.time.Instant#toString()

The following examples show how to use java.time.Instant#toString() . These examples are extracted from open source projects. 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
public <I extends QueryItem, H extends ColumnHeader<? super I>>
    ReportRepresentationModel toReportResource(Report<I, H> report, Instant time) {
  String[] header =
      report.getColumnHeaders().stream().map(H::getDisplayName).toArray(String[]::new);
  ReportRepresentationModel.MetaInformation meta =
      new ReportRepresentationModel.MetaInformation(
          report.getClass().getSimpleName(), time.toString(), header, report.getRowDesc());

  // iterate over each Row and transform it to a RowResource while keeping the domain key.
  List<ReportRepresentationModel.RowResource> rows =
      report.getRows().entrySet().stream()
          .sorted(Comparator.comparing(e -> e.getKey().toLowerCase()))
          .map(
              i ->
                  transformRow(
                      i.getValue(), i.getKey(), new String[report.getRowDesc().length], 0))
          .flatMap(Collection::stream)
          .collect(Collectors.toList());

  List<ReportRepresentationModel.RowResource> sumRow =
      transformRow(
          report.getSumRow(), meta.getTotalDesc(), new String[report.getRowDesc().length], 0);

  return new ReportRepresentationModel(meta, rows, sumRow);
}
 
Example 2
Source Project: GriefPrevention   File: EconomyDataConfig.java    License: MIT License 5 votes vote down vote up
@Override
public void setTaxPastDueDate(Instant date) {
    if (date == null) {
        this.taxPastDueDate = null;
    } else {
        this.taxPastDueDate = date.toString();
    }
}
 
Example 3
Source Project: spring-analysis-note   File: InstantFormatter.java    License: MIT License 4 votes vote down vote up
@Override
public String print(Instant object, Locale locale) {
	return object.toString();
}
 
Example 4
@Override
public String toNonNullValue(Instant value) {
    return value.toString();
}
 
Example 5
Source Project: GriefDefender   File: EconomyDataConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void setTaxPastDueDate(Instant date) {
    this.taxPastDueDate = date == null ? null : date.toString();
}
 
Example 6
Source Project: GriefDefender   File: EconomyDataConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void setRentStartDate(Instant date) {
    this.rentStartDate = date == null ? null : date.toString();
}
 
Example 7
Source Project: GriefDefender   File: EconomyDataConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void setRentEndDate(Instant date) {
    this.rentEndDate = date == null ? null : date.toString();
}
 
Example 8
@Override
public String getEnableOn()
{
   Instant trippedOn = circuitBreaker.enabledOn();
   return trippedOn == null ? "" : trippedOn.toString();
}
 
Example 9
@Override
public String marshal(Instant v) throws Exception {
    return v.toString();
}
 
Example 10
Source Project: emodb   File: JsonMap.java    License: Apache License 2.0 4 votes vote down vote up
static String format(Instant timestamp) {
    return timestamp != null ? timestamp.toString() : null;
}
 
Example 11
Source Project: GriefDefender   File: EconomyDataConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void setTaxPastDueDate(Instant date) {
    this.taxPastDueDate = date == null ? null : date.toString();
}
 
Example 12
Source Project: GriefDefender   File: EconomyDataConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void setRentEndDate(Instant date) {
    this.rentEndDate = date == null ? null : date.toString();
}
 
Example 13
@Override
public String print(Instant object, Locale locale) {
	return object.toString();
}
 
Example 14
@Override
public String toNonNullString(Instant value) {
    return value.toString();
}
 
Example 15
Source Project: staccato   File: QueryBuilderHelper.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Builds an Elasticsearch temporal query
 *
 * @param time The datetime values passed in the api request
 * @return The Elasticsearch query builder
 */

public static Optional<QueryBuilder> timeBuilder(String time) {
    if (null == time || time.isBlank()) {
        return Optional.empty();
    }
    String startTimeProperty;
    String endTimeProperty;

    if (time.indexOf("/") > 0) {
        String[] timeArray = time.split("/");
        startTimeProperty = dateStringOrOpenInterval(timeArray[0]);
        endTimeProperty = dateStringOrOpenInterval(timeArray[1]);
        if (endTimeProperty != null) {
            // check if end time is not null;
            // otherwise, NullPointerException will be thrown during parse
            try {
                // see if the value can be parsed into a period, eg P1Y2M3W4D
                Period period = Period.parse(endTimeProperty);

                Instant start = Instant.parse(startTimeProperty);
                Instant end = start.plus(period);

                start.plus(period.normalized());

                startTimeProperty = start.toString();
                endTimeProperty = end.toString();
            } catch (DateTimeParseException e) {
                // not a period
            }
        }
    } else {
        startTimeProperty = time;
        endTimeProperty = time;
    }
    RangeQueryBuilder rangeQueryBuilder = QueryBuilders
            .rangeQuery(FieldName.DATETIME_FULL)
            .from(startTimeProperty)
            .to(endTimeProperty);

    return Optional.of(rangeQueryBuilder);
}
 
Example 16
Source Project: java-technology-stack   File: InstantFormatter.java    License: MIT License 4 votes vote down vote up
@Override
public String print(Instant object, Locale locale) {
	return object.toString();
}
 
Example 17
Source Project: vertx-s3-client   File: InstantAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String marshal(Instant v) throws Exception {
    return v.toString();
}
 
Example 18
Source Project: java-trader   File: DateUtil.java    License: Apache License 2.0 4 votes vote down vote up
public static String instant2str(Instant instant) {
    if (instant == null) {
        return "";
    }
    return instant.toString();
}
 
Example 19
Source Project: GriefPrevention   File: ClaimDataConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void setDateLastActive(Instant date) {
    this.requiresSave = true;
    this.dateLastActive = date.toString();
}
 
Example 20
Source Project: mdw   File: Query.java    License: Apache License 2.0 4 votes vote down vote up
public static String getString(Instant instant) {
    return instant == null ? null : instant.toString();
}