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

The following examples show how to use java.time.Instant#toString() . 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
Source File: ReportRepresentationModelAssembler.java    From taskana with Apache License 2.0 6 votes vote down vote up
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 File: EconomyDataConfig.java    From GriefPrevention with 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 File: EconomyDataConfig.java    From GriefDefender with MIT License 4 votes vote down vote up
@Override
public void setRentEndDate(Instant date) {
    this.rentEndDate = date == null ? null : date.toString();
}
 
Example 4
Source File: Query.java    From mdw with Apache License 2.0 4 votes vote down vote up
public static String getString(Instant instant) {
    return instant == null ? null : instant.toString();
}
 
Example 5
Source File: ClaimDataConfig.java    From GriefPrevention with MIT License 4 votes vote down vote up
@Override
public void setDateLastActive(Instant date) {
    this.requiresSave = true;
    this.dateLastActive = date.toString();
}
 
Example 6
Source File: DateUtil.java    From java-trader with Apache License 2.0 4 votes vote down vote up
public static String instant2str(Instant instant) {
    if (instant == null) {
        return "";
    }
    return instant.toString();
}
 
Example 7
Source File: InstantAdapter.java    From vertx-s3-client with Apache License 2.0 4 votes vote down vote up
@Override
public String marshal(Instant v) throws Exception {
    return v.toString();
}
 
Example 8
Source File: InstantFormatter.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public String print(Instant object, Locale locale) {
	return object.toString();
}
 
Example 9
Source File: QueryBuilderHelper.java    From staccato with 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 10
Source File: TimestampColumnInstantMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public String toNonNullString(Instant value) {
    return value.toString();
}
 
Example 11
Source File: InstantFormatter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public String print(Instant object, Locale locale) {
	return object.toString();
}
 
Example 12
Source File: InstantFormatter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public String print(Instant object, Locale locale) {
	return object.toString();
}
 
Example 13
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 4 votes vote down vote up
@Override
public void setTaxPastDueDate(Instant date) {
    this.taxPastDueDate = date == null ? null : date.toString();
}
 
Example 14
Source File: JsonMap.java    From emodb with Apache License 2.0 4 votes vote down vote up
static String format(Instant timestamp) {
    return timestamp != null ? timestamp.toString() : null;
}
 
Example 15
Source File: MCRInstantXMLAdapter.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String marshal(Instant v) throws Exception {
    return v.toString();
}
 
Example 16
Source File: CircuitBreakerJMX.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
@Override
public String getEnableOn()
{
   Instant trippedOn = circuitBreaker.enabledOn();
   return trippedOn == null ? "" : trippedOn.toString();
}
 
Example 17
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 4 votes vote down vote up
@Override
public void setRentEndDate(Instant date) {
    this.rentEndDate = date == null ? null : date.toString();
}
 
Example 18
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 4 votes vote down vote up
@Override
public void setRentStartDate(Instant date) {
    this.rentStartDate = date == null ? null : date.toString();
}
 
Example 19
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 4 votes vote down vote up
@Override
public void setTaxPastDueDate(Instant date) {
    this.taxPastDueDate = date == null ? null : date.toString();
}
 
Example 20
Source File: StringColumnInstantMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public String toNonNullValue(Instant value) {
    return value.toString();
}