Пример #1
0
  private static ZoneId _getZoneId(ColumnDefinition<?, ?> columnDefinition) {
    if (columnDefinition.has(JavaZoneIdProperty.class)) {
      return columnDefinition.lookFor(JavaZoneIdProperty.class).getZoneId();
    } else if (columnDefinition.has(TimeZoneProperty.class)) {
      return columnDefinition.lookFor(TimeZoneProperty.class).getTimeZone().toZoneId();
    }

    return null;
  }
Пример #2
0
  public static DateTimeFormatter getDateTimeFormatter(ColumnDefinition<?, ?> columnDefinition) {
    DateTimeFormatter dtf;

    if (columnDefinition.has(JavaDateTimeFormatterProperty.class)) {
      dtf = columnDefinition.lookFor(JavaDateTimeFormatterProperty.class).getFormatter();
    } else if (columnDefinition.has(DateFormatProperty.class)) {
      dtf =
          DateTimeFormatter.ofPattern(
              columnDefinition.lookFor(DateFormatProperty.class).getPattern());
    } else {
      throw new IllegalArgumentException("No date format pattern specified");
    }

    final ZoneId zoneId = _getZoneId(columnDefinition);

    if (zoneId != null) {
      dtf = dtf.withZone(zoneId);
    } else if (dtf.getZone() == null) {
      dtf = dtf.withZone(ZoneId.systemDefault());
    }

    return dtf;
  }