Example usage for java.time ZoneId systemDefault

List of usage examples for java.time ZoneId systemDefault

Introduction

In this page you can find the example usage for java.time ZoneId systemDefault.

Prototype

public static ZoneId systemDefault() 

Source Link

Document

Gets the system default time-zone.

Usage

From source file:org.helioviewer.jhv.plugins.hekplugin.HEKPlugin.java

@Override
public void render(GL2 gl, PluginLayer _imageParams) {
    if (isVisible()) {
        LocalDateTime in = Plugins.SINGLETON.getCurrentDateTime();
        if (in != null) {
            Date currentDate = Date.from(in.atZone(ZoneId.systemDefault()).toInstant());
            List<HEKEvent> toDraw = HEKCache.getSingletonInstance().getModel().getActiveEvents(currentDate);
            if (toDraw != null && toDraw.size() > 0) {
                gl.glDisable(GL2.GL_TEXTURE_2D);
                gl.glEnable(GL2.GL_CULL_FACE);
                gl.glEnable(GL2.GL_LINE_SMOOTH);
                gl.glEnable(GL2.GL_BLEND);

                for (HEKEvent evt : toDraw)
                    drawPolygon(gl, evt, currentDate);

                gl.glDisable(GL2.GL_LINE_SMOOTH);

                gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
                gl.glDisable(GL2.GL_DEPTH_TEST);
                gl.glEnable(GL2.GL_TEXTURE_2D);
                gl.glColor4f(1.0f, 1.0f, 1.0f, 1);

                for (HEKEvent evt : toDraw)
                    drawIcon(gl, evt, currentDate);

                gl.glDisable(GL2.GL_TEXTURE_2D);
                gl.glDisable(GL2.GL_BLEND);
                gl.glEnable(GL2.GL_DEPTH_TEST);
                gl.glDisable(GL2.GL_CULL_FACE);
            }/*from  ww w  .jav  a2  s.c  om*/
        }
    }
}

From source file:org.wallride.web.support.RssFeedView.java

@SuppressWarnings("unchecked")
@Override/*from w  w w.ja  v a  2 s .co  m*/
protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    Set<Article> articles = (Set<Article>) model.get("articles");
    List<Item> items = new ArrayList<>(articles.size());
    for (Article article : articles) {
        Item item = new Item();
        item.setTitle(article.getTitle());
        item.setPubDate(Date.from(article.getDate().atZone(ZoneId.systemDefault()).toInstant()));
        Description description = new Description();
        description.setType("text/html");
        description.setValue(article.getBody());
        item.setDescription(description);
        item.setLink(link(article));
        items.add(item);
    }
    return items;
}

From source file:io.gravitee.reporter.elastic.engine.impl.AbstractElasticReportEngine.java

public AbstractElasticReportEngine() {
    this.sdf = java.time.format.DateTimeFormatter.ofPattern("yyyy.MM.dd").withZone(ZoneId.systemDefault());
    this.dtf = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZ");
}

From source file:org.sonatype.nexus.tasklog.TaskLogCleanup.java

void cleanup() {
    String taskLogsHome = getTaskLogHome();

    if (taskLogsHome == null) {
        // we are forgiving if the task logs home is not defined. Just log a message with a call to action.
        log.warn(/*w  ww .ja v a 2s  .  c  o  m*/
                "Unable to cleanup task log files. Please check that the 'tasklogfile' appender exists in logback.xml");
        return;
    }

    File logFilesHome = new File(taskLogsHome);

    log.info("Cleaning up log files in {} older than {} days", logFilesHome.getAbsolutePath(), numberOfDays);

    LocalDate now = LocalDate.now().minusDays(numberOfDays);
    Date thresholdDate = Date.from(now.atStartOfDay(ZoneId.systemDefault()).toInstant());
    AgeFileFilter ageFileFilter = new AgeFileFilter(thresholdDate);
    Iterator<File> filesToDelete = iterateFiles(logFilesHome, ageFileFilter, ageFileFilter);
    filesToDelete.forEachRemaining(f -> {
        try {
            forceDelete(f);
            log.info("Removed task log file {}", f.toString());
        } catch (IOException e) { // NOSONAR
            log.error("Unable to delete task file {}. Message was {}.", f.toString(), e.getMessage());
        }
    });
}

From source file:be.wegenenverkeer.common.resteasy.json.Iso8601AndOthersLocalDateTimeFormat.java

/**
 * Parse string to date./* w  w  w  .  j  a v a2s. c  o  m*/
 *
 * @param str string to parse
 * @return date
 */
public LocalDateTime parse(String str) {
    LocalDateTime date = null;

    if (StringUtils.isNotBlank(str)) {
        // try full ISO 8601 format first
        try {
            Date timestamp = ISO8601Utils.parse(str, new ParsePosition(0));
            Instant instant = Instant.ofEpochMilli(timestamp.getTime());
            return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
        } catch (IllegalArgumentException | ParseException ex) {
            // ignore, try next format
            date = null; // dummy
        }
        // then try ISO 8601 format without timezone
        try {
            return LocalDateTime.from(iso8601NozoneFormat.parse(str));
        } catch (IllegalArgumentException | DateTimeParseException ex) {
            // ignore, try next format
            date = null; // dummy
        }

        // then try a list of formats
        for (DateTimeFormatter formatter : FORMATS) {
            try {
                TemporalAccessor ta = formatter.parse(str);
                try {
                    return LocalDateTime.from(ta);
                } catch (DateTimeException dte) {
                    return LocalDate.from(ta).atStartOfDay();
                }
            } catch (IllegalArgumentException | DateTimeParseException e) {
                // ignore, try next format
                date = null; // dummy
            }
        }
        throw new IllegalArgumentException("Could not parse date " + str
                + " using ISO 8601 or any of the formats " + Arrays.asList(FORMATS) + ".");

    }
    return date; // empty string
}

From source file:com.netflix.spinnaker.echo.pipelinetriggers.health.MonitoredPollerHealth.java

private void polledRecently(Health.Builder builder) {
    Instant lastPollTimestamp = poller.getLastPollTimestamp();
    if (lastPollTimestamp == null) {
        builder.unknown();/* w ww  . j  a va  2s  .  c  om*/
    } else {
        val timeSinceLastPoll = Duration.between(lastPollTimestamp, now());
        builder.withDetail("last.polled",
                formatDurationWords(timeSinceLastPoll.toMillis(), true, true) + " ago");
        builder.withDetail("last.polled.at",
                ISO_LOCAL_DATE_TIME.format(lastPollTimestamp.atZone(ZoneId.systemDefault())));
        if (timeSinceLastPoll.compareTo(Duration.of(poller.getPollingIntervalSeconds() * 2, SECONDS)) <= 0) {
            builder.up();
        } else {
            builder.down();
        }
    }
}

From source file:org.jimsey.projects.turbine.fuel.domain.IndicatorJson.java

@JsonCreator
public IndicatorJson(@JsonProperty("date") long date, @JsonProperty("close") double close,
        @JsonProperty("indicators") Map<String, Double> indicators, @JsonProperty("symbol") String symbol,
        @JsonProperty("market") String market, @JsonProperty("name") String name,
        @JsonProperty("timestamp") String timestamp) {
    this(OffsetDateTime.ofInstant(Instant.ofEpochMilli(date), ZoneId.systemDefault()), close, indicators,
            symbol, market, name, timestamp);
}

From source file:com.sumzerotrading.intraday.trading.strategy.ReportGeneratorTest.java

@Before
public void setUp() throws Exception {
    orderFilledTime = ZonedDateTime.of(2015, 3, 15, 12, 30, 33, 0, ZoneId.systemDefault());
    reportGenerator = spy(ReportGenerator.class);
    order = new TradeOrder("123", new StockTicker("QQQ"), 100, TradeDirection.BUY);
    order.setOrderFilledTime(orderFilledTime);
    String systemTmpDir = System.getProperty("java.io.tmpdir");
    if (!systemTmpDir.endsWith("/")) {
        systemTmpDir += "/";
    }/*  www.java  2s .c  om*/

    System.out.println("System tmp dir is: " + systemTmpDir);
    tmpDir = systemTmpDir + "rg-test/";
    partialDir = tmpDir + "partial/";
    FileUtils.deleteDirectory(new File(tmpDir));
}

From source file:scouterx.webapp.request.SummaryRequest.java

private void setTimeAsYmd() {
    ZoneId zoneId = ZoneId.systemDefault();
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
    LocalDateTime startDateTime = LocalDateTime.parse(startYmdHm, formatter);
    LocalDateTime endDateTime = LocalDateTime.parse(endYmdHm, formatter);

    startTimeMillis = startDateTime.atZone(zoneId).toEpochSecond() * 1000L;
    endTimeMillis = endDateTime.atZone(zoneId).toEpochSecond() * 1000L;
}

From source file:com.orange.clara.cloud.servicedbdumper.task.ScheduledManagingJobTask.java

@Scheduled(fixedDelay = 1200000)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void cleaningDeletedDumpFile() {
    logger.debug("Running: cleaning deleted dump task ...");
    List<DatabaseDumpFile> databaseDumpFiles = this.databaseDumpFileRepo.findByDeletedTrueOrderByDeletedAtAsc();
    LocalDateTime whenRemoveDateTime;
    for (DatabaseDumpFile databaseDumpFile : databaseDumpFiles) {
        whenRemoveDateTime = LocalDateTime
                .from(databaseDumpFile.getDeletedAt().toInstant().atZone(ZoneId.systemDefault()))
                .plusDays(this.dumpDeleteExpirationDays);
        if (LocalDateTime.from(Calendar.getInstance().toInstant().atZone(ZoneId.systemDefault()))
                .isBefore(whenRemoveDateTime)) {
            continue;
        }/*ww w . j a  v  a2s  . c o m*/
        this.deleter.delete(databaseDumpFile);
    }
    logger.debug("Finished: cleaning deleted dump task.");
}