/** * Converts this date-time to a {@code ZonedDateTime} using the offset as the zone ID. * <p> * This creates the simplest possible {@code ZonedDateTime} using the offset * as the zone ID. * <p> * To control the time-zone used, see {@link #atZoneSameInstant(ZoneId)} and * {@link #atZoneSimilarLocal(ZoneId)}. * * @return a zoned date-time representing the same local date-time and offset, not null */ public ZonedDateTime toZonedDateTime() { return ZonedDateTime.of(dateTime, offset); }
/** * Converts this date-time to a {@code ZonedDateTime} using the offset as the zone ID. * <p> * This creates the simplest possible {@code ZonedDateTime} using the offset * as the zone ID. * <p> * To control the time-zone used, see {@link #atZoneSameInstant(ZoneId)} and * {@link #atZoneSimilarLocal(ZoneId)}. * * @return a zoned date-time representing the same local date-time and offset, not null */ public ZonedDateTime toZonedDateTime() { return ZonedDateTime.of(dateTime, offset); }
return ZonedDateTime.of(this, zone);
return ZonedDateTime.of(this, zone);
/** * Obtains an instance of {@code ZonedDateTime} from a local date and time. * <p> * This creates a zoned date-time matching the input local date and time as closely as possible. * Time-zone rules, such as daylight savings, mean that not every local date-time * is valid for the specified zone, thus the local date-time may be adjusted. * <p> * The local date time and first combined to form a local date-time. * The local date-time is then resolved to a single instant on the time-line. * This is achieved by finding a valid offset from UTC/Greenwich for the local * date-time as defined by the {@link ZoneRules rules} of the zone ID. *<p> * In most cases, there is only one valid offset for a local date-time. * In the case of an overlap, when clocks are set back, there are two valid offsets. * This method uses the earlier offset typically corresponding to "summer". * <p> * In the case of a gap, when clocks jump forward, there is no valid offset. * Instead, the local date-time is adjusted to be later by the length of the gap. * For a typical one hour daylight savings change, the local date-time will be * moved one hour later into the offset typically corresponding to "summer". * * @param date the local date, not null * @param time the local time, not null * @param zone the time-zone, not null * @return the offset date-time, not null */ public static ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone) { return of(LocalDateTime.of(date, time), zone); }
/** * Obtains an instance of {@code ZonedDateTime} from a local date and time. * <p> * This creates a zoned date-time matching the input local date and time as closely as possible. * Time-zone rules, such as daylight savings, mean that not every local date-time * is valid for the specified zone, thus the local date-time may be adjusted. * <p> * The local date time and first combined to form a local date-time. * The local date-time is then resolved to a single instant on the time-line. * This is achieved by finding a valid offset from UTC/Greenwich for the local * date-time as defined by the {@link ZoneRules rules} of the zone ID. *<p> * In most cases, there is only one valid offset for a local date-time. * In the case of an overlap, when clocks are set back, there are two valid offsets. * This method uses the earlier offset typically corresponding to "summer". * <p> * In the case of a gap, when clocks jump forward, there is no valid offset. * Instead, the local date-time is adjusted to be later by the length of the gap. * For a typical one hour daylight savings change, the local date-time will be * moved one hour later into the offset typically corresponding to "summer". * * @param date the local date, not null * @param time the local time, not null * @param zone the time-zone, not null * @return the offset date-time, not null */ public static ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone) { return of(LocalDateTime.of(date, time), zone); }
@Override public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages, Set<String> allowedSubtypes) { Map<String, String> params = new HashMap<>(); params.put("channel", channelId); if (day != null) { ZonedDateTime start = ZonedDateTime.of(day.atStartOfDay(), ZoneId.of("UTC")); ZonedDateTime end = ZonedDateTime.of(day.atStartOfDay().plusDays(1).minus(1, ChronoUnit.MILLIS), ZoneId.of("UTC")); params.put("oldest", convertDateToSlackTimestamp(start)); params.put("latest", convertDateToSlackTimestamp(end)); } if (numberOfMessages > -1) { params.put("count", String.valueOf(numberOfMessages)); } else { params.put("count", String.valueOf(DEFAULT_HISTORY_FETCH_SIZE)); } SlackChannel channel = session.findChannelById(channelId); switch (channel.getType()) { case INSTANT_MESSAGING: return fetchHistoryOfChannel(params,FETCH_IM_HISTORY_COMMAND, allowedSubtypes); case PRIVATE_GROUP: return fetchHistoryOfChannel(params,FETCH_GROUP_HISTORY_COMMAND, allowedSubtypes); default: return fetchHistoryOfChannel(params,FETCH_CHANNEL_HISTORY_COMMAND, allowedSubtypes); } }
return of(ldt, zone); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain ZonedDateTime from TemporalAccessor: " +
return of(ldt, zone); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain ZonedDateTime from TemporalAccessor: " +
return ZonedDateTime.of(ldt, zone);
return ZonedDateTime.of(ldt, zone);