Java Code Examples for java.time.OffsetDateTime#getSecond()

The following examples show how to use java.time.OffsetDateTime#getSecond() . 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: PNGMetadata.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
void initImageCreationTime(OffsetDateTime offsetDateTime) {
    // Check for incoming arguments
    if (offsetDateTime != null) {
        // set values that make up Standard/Document/ImageCreationTime
        creation_time_present = true;
        creation_time_year    = offsetDateTime.getYear();
        creation_time_month   = offsetDateTime.getMonthValue();
        creation_time_day     = offsetDateTime.getDayOfMonth();
        creation_time_hour    = offsetDateTime.getHour();
        creation_time_minute  = offsetDateTime.getMinute();
        creation_time_second  = offsetDateTime.getSecond();
        creation_time_offset  = offsetDateTime.getOffset();
    }
}
 
Example 2
Source File: ASN1Type.java    From xipki with Apache License 2.0 5 votes vote down vote up
public static int writeGeneralizedTime(Date time, byte[] out, int offset) {
  OffsetDateTime offsetTime = time.toInstant().atOffset(ZoneOffset.UTC);
  int idx = offset;
  out[idx++] = 0x18;
  out[idx++] = 15;
  // yyyyMMddhhmmssZ
  // year
  int year = offsetTime.getYear();
  out[idx++] = (byte) (0x30 + year / 1000);
  out[idx++] = (byte) (0x30 + year / 100 % 10);
  out[idx++] = (byte) (0x30 + year / 10 % 10);
  out[idx++] = (byte) (0x30 + year % 10);
  // month
  int month = offsetTime.getMonthValue();
  out[idx++] = (byte) (0x30 + month / 10);
  out[idx++] = (byte) (0x30 + month % 10);
  // day
  int day = offsetTime.getDayOfMonth();
  out[idx++] = (byte) (0x30 + day / 10);
  out[idx++] = (byte) (0x30 + day % 10);
  // hour
  int hour = offsetTime.getHour();
  out[idx++] = (byte) (0x30 + hour / 10);
  out[idx++] = (byte) (0x30 + hour % 10);
  // minute
  int minute = offsetTime.getMinute();
  out[idx++] = (byte) (0x30 + minute / 10);
  out[idx++] = (byte) (0x30 + minute % 10);
  // second
  int second = offsetTime.getSecond();
  out[idx++] = (byte) (0x30 + second / 10);
  out[idx++] = (byte) (0x30 + second % 10);
  out[idx++] = 'Z';
  return idx - offset;
}
 
Example 3
Source File: Time.java    From java-timeseries with MIT License 4 votes vote down vote up
private boolean timeEmpty(OffsetDateTime dateTime) {
  return dateTime.getHour() == 0
      && dateTime.getMinute() == 0
      && dateTime.getSecond() == 0
      && dateTime.getNano() == 0;
}
 
Example 4
Source File: Time.java    From java-timeseries with MIT License 4 votes vote down vote up
private void addMinute(OffsetDateTime dateTime, StringBuilder builder) {
  if (!(dateTime.getMinute() == 0 && dateTime.getSecond() == 0)) {
    builder.append(":mm");
  }
}
 
Example 5
Source File: Time.java    From java-timeseries with MIT License 4 votes vote down vote up
private void addSecond(OffsetDateTime dateTime, StringBuilder builder) {
  if (dateTime.getSecond() != 0) {
    builder.append(":ss");
  }
}