List of usage examples for java.time ZoneId systemDefault
public static ZoneId systemDefault()
From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java
public static LocalDateTime getLocalDateTime(Date date) { Instant instant = Instant.ofEpochMilli(date.getTime()); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); }
From source file:org.edgexfoundry.scheduling.ScheduleContext.java
public void reset(Schedule schedule) { if ((this.schedule != null) && (this.schedule.getName() != schedule.getName())) { scheduleEvents.clear();/*ww w .j av a2s.c o m*/ } this.schedule = schedule; // update this if/when iterations are added to the schedule this.maxIterations = (schedule.getRunOnce()) ? 1 : 0; this.iterations = 0; String start = schedule.getStart(); String end = schedule.getEnd(); // if start is empty, then use now (need to think about ever-spawning tasks) if (start == null || start.isEmpty()) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Schedule.DATETIME_FORMATS[0]) .withZone(ZoneId.systemDefault()); start = formatter.format(Instant.now()); } this.startTime = parseTime(start); // if end is empty, then use max if (end == null || end.isEmpty()) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Schedule.DATETIME_FORMATS[0]) .withZone(ZoneId.systemDefault()); end = formatter.format(ZonedDateTime.of(LocalDateTime.MAX, ZoneId.systemDefault())); } this.endTime = parseTime(end); // get the period and duration from the frequency string parsePeriodAndDuration(schedule.getFrequency()); // setup the next time the schedule will run this.nextTime = initNextTime(startTime, ZonedDateTime.now(), period, duration); // clear any schedule events as required logger.debug("reset() " + this.toString()); }
From source file:com.prodigious.festivities.api.bean.Festivity.java
@Override @JsonIgnore//from w w w. ja v a 2s.co m public LocalDate getEndDate() { if (end == null) { return null; } return end.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); }
From source file:io.syndesis.github.GitHubServiceImpl.java
@Override public User getApiUser() throws IOException { final User user = userService.getUser(); // if the user did not elect to publicly display his e-mail address, e-mail will be null // https://developer.github.com/v3/users/#get-a-single-user // let's put a dummy e-mail address then, as it is needed for the commit if (user.getEmail() == null) { // users before 2017-07-18 have their no-reply e-mail addresses in the form // username@users.noreply.github.com, and after that date // id+username@users.noreply.github.com // https://help.github.com/articles/about-commit-email-addresses/ final LocalDate createdAt = user.getCreatedAt().toInstant().atZone(ZoneId.systemDefault()) .toLocalDate();// www. ja v a 2 s .c om if (createdAt.isAfter(GITHUB_NOREPLY_EMAIL_CUTOFF)) { user.setEmail(user.getId() + "+" + user.getLogin() + "@users.noreply.github.com"); } else { user.setEmail(user.getLogin() + "@users.noreply.github.com"); } } return user; }
From source file:alfio.model.EventStatistic.java
@Override public int compareTo(EventStatistic o) { CompareToBuilder builder = new CompareToBuilder(); return builder.append(isExpired(), o.isExpired()) .append(event.getBegin().withZoneSameInstant(ZoneId.systemDefault()), o.event.getBegin().withZoneSameInstant(ZoneId.systemDefault())) .build();/* w w w .ja va2 s . c o m*/ }
From source file:org.apache.metron.parsers.snort.BasicSnortParser.java
private DateTimeFormatter getDateFormatterWithZone(DateTimeFormatter formatter, Map<String, Object> parserConfig) { String timezone = (String) parserConfig.get("timeZone"); if (StringUtils.isNotEmpty(timezone)) { if (ZoneId.getAvailableZoneIds().contains(timezone)) { _LOG.info("Using timezone '{}'", timezone); return formatter.withZone(ZoneId.of(timezone)); } else {//w ww . j av a 2 s. c o m throw new IllegalArgumentException("Unable to find ZoneId '" + timezone + "'"); } } else { _LOG.info("Using default timezone '{}'", ZoneId.systemDefault()); return formatter.withZone(ZoneId.systemDefault()); } }
From source file:com.buffalokiwi.api.APIDate.java
/** * Attempt to take some value and turn it into a valid APIDate. * If it isn't valid, then this returns null. * //from ww w. j a v a 2s . c om * @param value Jet value * @return date or null */ public static APIDate fromStringOrNull(String value) { if (value == null || value.isEmpty()) return null; for (final DateTimeFormatter fmt : FORMATS) { try { final TemporalAccessor t = fmt.parse(value); try { return new APIDate(ZonedDateTime.from(t)); } catch (DateTimeException e) { APILog.warn(LOG, e, "Failed to determine timezone. Defaulting to local offset"); final LocalDateTime local = LocalDateTime.from(t); final ZoneOffset offset = ZoneId.systemDefault().getRules().getOffset(Instant.now()); return new APIDate(ZonedDateTime.of(local, offset)); } } catch (DateTimeParseException e) { //..do nothing, yet. } } //..Not found. Log it and return null APILog.error(LOG, "Failed to parse date string:", value); return null; }
From source file:net.ceos.project.poi.annotated.core.CsvHandler.java
/** * Apply a LocalDate value to the object. * // w w w .ja va 2s . com * @param o * the object * @param field * the field * @param xlsAnnotation * the {@link XlsElement} annotation * @param values * the array with the content at one line * @param idx * the index of the field * @throws ConverterException * the conversion exception type */ protected static void localDateReader(final Object o, final Field field, final XlsElement xlsAnnotation, final String[] values, final int idx) throws ConverterException { if (StringUtils.isNotBlank(values[idx])) { try { field.set(o, applyMaskToDate(xlsAnnotation, values, idx).toInstant().atZone(ZoneId.systemDefault()) .toLocalDate()); } catch (IllegalArgumentException | IllegalAccessException e) { throw new ConverterException(ExceptionMessage.CONVERTER_LOCALDATE.getMessage(), e); } } }
From source file:org.jimsey.projects.turbine.fuel.domain.TickJson.java
@JsonCreator public TickJson(@JsonProperty("date") long date, @JsonProperty("open") double open, @JsonProperty("high") double high, @JsonProperty("low") double low, @JsonProperty("close") double close, @JsonProperty("volume") double volume, @JsonProperty("symbol") String symbol, @JsonProperty("market") String market, @JsonProperty("timestamp") String timestamp) { this(OffsetDateTime.ofInstant(Instant.ofEpochMilli(date), ZoneId.systemDefault()), open, high, low, close, volume, symbol, market, timestamp); }
From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java
public static Date toDate(LocalDateTime ldt) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); GregorianCalendar cal = GregorianCalendar.from(zdt); return cal.getTime(); }