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:com.fantasy.stataggregator.workers.GameDataRetrieverTask.java

/**
 * Determines if a game has already been played, No current game data<br>
 * will be pulled, since the statistics aren't final.
 *
 * @param sched//from  w  ww. j  a va 2s  .c  o m
 * @return
 */
private boolean hasBeenPlayed(GameSchedule sched) throws ParseException {
    Date gameDate = sched.getGamedate();
    if (Objects.nonNull(gameDate)) {
        LocalDate dateOnly = LocalDateTime.ofInstant(gameDate.toInstant(), ZoneId.systemDefault())
                .toLocalDate();

        return dateOnly.isBefore(LocalDate.now());
    }
    return false;
}

From source file:com.github.aptd.simulation.datamodel.CXMLReader.java

@Override
@SuppressWarnings("unchecked")
public final IExperiment get(final IFactory p_factory, final String p_datamodel, final long p_simulationsteps,
        final boolean p_parallel, final String p_timemodel,
        final Supplier<RealDistribution> p_platformchangedurationdistributionsupplier,
        final int p_numberofpassengers, final double p_lightbarrierminfreetime, final double p_delayseconds) {
    try (final FileInputStream l_stream = new FileInputStream(p_datamodel)) {
        final Asimov l_model = (Asimov) m_context.createUnmarshaller().unmarshal(l_stream);

        // time definition

        final Instant l_starttime = ZonedDateTime.now(ZoneId.systemDefault())
                .with(ChronoField.CLOCK_HOUR_OF_DAY, 8).with(ChronoField.MINUTE_OF_HOUR, 45)
                .with(ChronoField.SECOND_OF_MINUTE, 0).with(ChronoField.NANO_OF_SECOND, 0)
                .with(ChronoField.DAY_OF_MONTH, 3).with(ChronoField.MONTH_OF_YEAR, 10)
                .with(ChronoField.YEAR, 2017).toInstant();

        final ITime l_time = "jump".equals(p_timemodel) ? new CJumpTime(l_starttime, p_simulationsteps)
                : new CStepTime(l_starttime, Duration.ofSeconds(1), p_simulationsteps);

        final CMessenger l_messenger = new CMessenger();

        final Set<IAction> l_actionsfrompackage = CCommon.actionsFromPackage().collect(Collectors.toSet());

        // asl agent definition
        final Map<String, String> l_agentdefs = agents(l_model.getAi());

        // macro (train-network) and microscopic model
        final Map<String, IPlatform<?>> l_platform = platform(l_model.getNetwork(), l_agentdefs, p_factory,
                l_time);//from w  w  w  .j  a  v a 2 s .  c  om
        final Map<String, IStation<?>> l_station = station(l_model.getNetwork(), l_agentdefs, p_factory, l_time,
                l_platform);
        final Pair<Map<String, ITrain<?>>, Map<String, IDoor<?>>> l_train = train(l_model.getNetwork(),
                l_agentdefs, p_factory, l_time, p_lightbarrierminfreetime);

        final Map<String, IElement<?>> l_agents = new HashMap<>();
        l_agents.putAll(l_platform);
        l_agents.putAll(l_station);
        l_agents.putAll(l_train.getLeft());
        l_agents.putAll(l_train.getRight());

        final CExperiment l_experiment = new CExperiment(p_simulationsteps, p_parallel, IStatistic.EMPTY,
                l_agents, l_time, l_messenger);

        // @todo create passengersources and their passenger generators according to scenario definition

        final IElement.IGenerator<IPassenger<?>> l_passengergenerator = passengergenerator(p_factory,
                "+!activate <-\n    state/transition\n.", l_actionsfrompackage, l_time);

        l_experiment.addAgent("passengersource_test",
                passengersourcegenerator(p_factory, "+!activate <-\n    state/transition\n.",
                        l_actionsfrompackage, l_time).generatesingle(new UniformRealDistribution(0.0, 1.0),
                                l_time.current().toEpochMilli(), p_numberofpassengers, l_passengergenerator,
                                l_experiment, l_agents.get("toy-node-1"),
                                p_platformchangedurationdistributionsupplier.get()));

        l_messenger.experiment(l_experiment);

        // experiment (executable model)
        return l_experiment;

    } catch (final Exception l_execption) {
        throw new CRuntimeException(l_execption);
    }
}

From source file:reactivity.SseController.java

/**
 * <p>//from  w ww.ja  v a2s  .c o m
 * Retrieves and pushes the timeseries associated to the given artifact.
 * </p>
 *
 * @param a the artifact associated to timeseries
 */
private void timeseries(final Artifact a) {

    // Compute the key
    final LocalDateTime i = LocalDateTime.ofInstant(Instant.ofEpochMilli(a.getTimestamp()),
            ZoneId.systemDefault());
    final Object[] key = new Object[] { a.getGroup().getType() + "/" + a.getGroup().getName(), i.getYear(),
            i.getMonthValue(), i.getDayOfMonth() };

    repository.color(key).subscribe((item) -> replayProcessor.onNext(sse(Artifact.class.cast(item))));
}

From source file:fi.ilmoeuro.membertrack.holvi.HolviPopulator.java

private void createSubscriptionPeriod(ProductMapping mapping, int i, Person person, Order order) {
    sessionRunner.exec(token -> {//w w  w  .  j  a  v  a2s.c o m
        Services services = servicesFactory.create(token);
        Service service = services.findById(mapping.getServiceUUID());
        if (service == null) {
            throw new ServiceNotFoundException(mapping.getServiceUUID());
        }

        double payment = mapping.getPayment();
        int euros = (int) (Math.floor(payment));
        int cents = (int) ((payment - euros) * 100);
        LocalDate orderDate = order.getPaid_time().withZoneSameInstant(ZoneId.systemDefault()).toLocalDate();
        SubscriptionPeriod sp = new SubscriptionPeriod(service, person, orderDate, mapping.getTimeUnit(),
                mapping.getLength(), euros * 100 + cents, false);
        SubscriptionPeriodHolviHandle hh = new SubscriptionPeriodHolviHandle(sp, config.getPoolHandle(),
                order.getCode(), i, orderDate);

        UnitOfWork uow = uowFactory.create(token);
        uow.addEntity(sp);
        uow.addEntity(hh);
        uow.execute();
    });
}

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

@Transactional
public void purgeFinishedJob() {
    LocalDateTime whenRemoveDateTime;
    List<Job> jobs = jobRepo.findByJobEventOrderByUpdatedAtDesc(JobEvent.FINISHED);
    for (Job job : jobs) {
        whenRemoveDateTime = LocalDateTime.from(job.getUpdatedAt().toInstant().atZone(ZoneId.systemDefault()))
                .plusMinutes(this.jobFinishedDeleteExpirationMinutes);
        if (LocalDateTime.from(Calendar.getInstance().toInstant().atZone(ZoneId.systemDefault()))
                .isBefore(whenRemoveDateTime)
                && (job.getDatabaseRefSrc() != null || job.getDbDumperServiceInstance() != null
                        || job.getDatabaseRefTarget() != null)) {
            continue;
        }/*from  w  w w . ja v a 2 s .  c o m*/
        this.jobRepo.delete(job);
    }
}

From source file:software.coolstuff.springframework.owncloud.service.impl.local.OwncloudLocalResourceServiceTest.java

private void modifyResourceInformationBasedOnPathInformation(OwncloudTestResourceImpl owncloudResource) {
    Path resourcePath = resolveRelativePath(Paths.get(owncloudResource.getHref().getPath()));
    try {//ww w. j a  va  2  s. c o m
        LocalDateTime lastModifiedAt = LocalDateTime
                .ofInstant(Files.getLastModifiedTime(resourcePath).toInstant(), ZoneId.systemDefault());
        owncloudResource.setLastModifiedAt(lastModifiedAt);
    } catch (IOException e) {
        e.printStackTrace(System.err);
        throw new IllegalStateException("Error while getting last modified time of Resource " + resourcePath,
                e);
    }
}

From source file:currency.converter.openexchangerate.OpenExchangeCurrencyConverter.java

/**
 * Saves currency exchange rate history of the logged in user
 * /* ww  w.ja v a2s .c o  m*/
 * @param rates Currency rates to be saved
 * @param baseCurrency Base currency which was used in the search
 * @param amount Amount of base currency
 * @param dateOfRate Date when the search was performed
 * @param userName Username of the user who has searched the exchange rate
 * 
 * @throws InvalidParameterException for invalid arguments
 */
private void saveExchangeRate(CurrencyRateModel rates, String baseCurrency, double amount, LocalDate dateOfRate,
        String userName) throws InvalidParameterException {

    Currency currency = getCurrency(baseCurrency);
    Date date = Date.from(dateOfRate.atStartOfDay(ZoneId.systemDefault()).toInstant());

    CurrencyHistory currencyHistory = new CurrencyHistory(currency.getId(), amount, date, userName);
    historyRepository.save(currencyHistory);

    // Save rates
    saveCurrencyRates(currencyHistory, rates, baseCurrency);
}

From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java

@SuppressWarnings({ "unchecked", "serial" })
@BeforeEach/*from w ww  .j a  v  a  2 s .  c  om*/
public void setup(@TestManagedMock UserProvider userProvider,
        @TestManagedMock ComponentInstanceRoutingMapProviderByInstance componentInstanceRoutingMapProviderByInstance,
        @TestManagedMock ComponentInstanceRoutingMapProvider componentInstanceRoutingMapProvider,
        @TestManagedMock SilverpeasComponentInstanceProvider silverpeasComponentInstanceProvider,
        @TestManagedMock SilverpeasComponentInstance componentInstance) {
    when(componentInstance.getName()).thenReturn(COMPONENT_NAME);
    when(silverpeasComponentInstanceProvider.getById(INSTANCE_ID)).thenReturn(Optional.of(componentInstance));
    when(silverpeasComponentInstanceProvider.getComponentName(INSTANCE_ID)).thenReturn("componentNameTest");

    when(componentInstanceRoutingMapProviderByInstance.getByInstanceId(INSTANCE_ID))
            .thenReturn(componentInstanceRoutingMapProvider);
    when(componentInstanceRoutingMapProvider.absolute()).thenReturn(componentInstanceRoutingMap);

    UserPreferences userPreferences = new UserPreferences("26", "fr", ZoneId.systemDefault(), null, null, false,
            false, false, UserMenuDisplay.DEFAULT);
    receiver = mock(User.class);
    when(receiver.getId()).thenReturn("26");
    when(receiver.getUserPreferences()).thenReturn(userPreferences);

    when(userProvider.getUser(receiver.getId())).thenReturn(receiver);
    reflectionRule.setField(DisplayI18NHelper.class, Locale.getDefault().getLanguage(), "defaultLanguage");
}

From source file:daylightchart.daylightchart.chart.DaylightChart.java

private void createDSTMarker(final XYPlot plot) {
    if (!riseSetData.usesDaylightTime()) {
        return;//from   ww  w . j av  a  2  s.  c  o m
    }

    final long intervalStart = riseSetData.getDstStartDate().atStartOfDay().atZone(ZoneId.systemDefault())
            .toInstant().toEpochMilli();
    final long intervalEnd = riseSetData.getDstEndDate().atStartOfDay().atZone(ZoneId.systemDefault())
            .toInstant().toEpochMilli();
    final IntervalMarker dstMarker = new IntervalMarker(intervalStart, intervalEnd,
            ChartConfiguration.nightColor, new BasicStroke(0.0f), null, null, 0.4f);
    dstMarker.setLabelPaint(Color.WHITE);
    dstMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    dstMarker.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT);
    //
    plot.addDomainMarker(dstMarker, Layer.BACKGROUND);
}

From source file:org.apache.geode.management.internal.cli.functions.ExportLogsFunction.java

public static LocalDateTime parseTime(String dateString) {
    if (dateString == null) {
        return null;
    }//from w w  w. j  a  v a 2 s.c  om

    try {
        SimpleDateFormat df = new SimpleDateFormat(ExportLogsCommand.FORMAT);
        return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
    } catch (ParseException e) {
        try {
            SimpleDateFormat df = new SimpleDateFormat(ExportLogsCommand.ONLY_DATE_FORMAT);
            return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
        } catch (ParseException e1) {
            return null;
        }
    }
}