Java Code Examples for com.google.protobuf.Timestamp#getSeconds()

The following examples show how to use com.google.protobuf.Timestamp#getSeconds() . 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: StatsService.java    From feast with Apache License 2.0 6 votes vote down vote up
private void validateRequest(GetFeatureStatisticsRequest request) {
  if (request.getIngestionIdsCount() == 0) {
    Timestamp startDate = request.getStartDate();
    Timestamp endDate = request.getEndDate();
    if (!request.hasStartDate() || !request.hasEndDate()) {
      throw new IllegalArgumentException(
          "Invalid request. Either provide dataset ids to retrieve statistics over, or a start date and end date.");
    }
    if (endDate.getSeconds() < startDate.getSeconds()) {
      throw new IllegalArgumentException(
          String.format(
              "Invalid request. Start timestamp %d is greater than the end timestamp %d",
              startDate.getSeconds(), endDate.getSeconds()));
    }
  }
}
 
Example 2
Source File: DateUtil.java    From feast with Apache License 2.0 5 votes vote down vote up
public static Timestamp maxTimestamp(Timestamp a, Timestamp b) {
  if (a.getSeconds() != b.getSeconds()) {
    return a.getSeconds() < b.getSeconds() ? b : a;
  } else {
    return a.getNanos() < b.getNanos() ? b : a;
  }
}
 
Example 3
Source File: DateUtil.java    From feast with Apache License 2.0 4 votes vote down vote up
public static DateTime toDateTime(Timestamp timestamp) {
  long millis = timestamp.getSeconds() * 1000 + (timestamp.getNanos() / 1000000);
  return new DateTime(millis, DateTimeZone.UTC);
}
 
Example 4
Source File: StatsDataset.java    From feast with Apache License 2.0 4 votes vote down vote up
public void subsetByDate(Timestamp date) {
  DateTime dateTime = new DateTime(date.getSeconds() * 1000, DateTimeZone.UTC);
  DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
  this.date = fmt.print(dateTime);
}