Example usage for java.time DateTimeException getMessage

List of usage examples for java.time DateTimeException getMessage

Introduction

In this page you can find the example usage for java.time DateTimeException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.eclipse.smarthome.core.internal.i18n.I18nProviderImpl.java

private void setTimeZone(final @Nullable String zoneId) {
    ZoneId oldTimeZone = this.timeZone;
    if (StringUtils.isBlank(zoneId)) {
        timeZone = null;/*  ww w  .ja v  a2s  . c  o m*/
    } else {
        try {
            timeZone = ZoneId.of(zoneId);
        } catch (DateTimeException e) {
            logger.warn("Error setting time zone '{}', falling back to the default time zone: {}", zoneId,
                    e.getMessage());
            timeZone = null;
        }
    }

    if (oldTimeZone != null && this.timeZone == null) {
        logger.info("Time zone is not set, falling back to the default time zone.");
    } else if (this.timeZone != null && !this.timeZone.equals(oldTimeZone)) {
        logger.info("Time zone set to '{}'.", this.timeZone);
    }
}

From source file:org.trellisldp.http.impl.HttpUtils.java

private static Optional<Instant> parseDate(final String date) {
    return ofNullable(date).map(String::trim).flatMap(d -> {
        try {//from   w  ww  . jav  a  2 s . c  o  m
            return of(parse(d, RFC_1123_DATE_TIME));
        } catch (final DateTimeException ex) {
            LOGGER.debug("Ignoring invalid date ({}): {}", date, ex.getMessage());
        }
        return empty();
    }).map(ZonedDateTime::toInstant);
}