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.hotelbeds.hotelapimodel.auto.util.AssignUtils.java

public static Date getDate(final LocalDateTime localDateTime) {
    Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
    return Date.from(instant);
}

From source file:org.ojbc.util.model.rapback.IdentificationResultSearchRequest.java

public void setReportedDateEndLocalDate(LocalDate localDate) {
    this.reportedDateEndDate = localDate == null ? null
            : Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}

From source file:org.ops4j.pax.web.resources.extender.internal.IndexedOsgiResourceLocator.java

@Override
public void register(final Bundle bundle) {
    Collection<URL> urls;
    try {//from w w w . j av  a 2 s  . co  m
        urls = Collections.list(bundle.findEntries(RESOURCE_ROOT, "*.*", true));
    } catch (IllegalStateException e) {
        logger.error("Error retrieving bundle-resources from bundle '{}'", bundle.getSymbolicName(), e);
        urls = Collections.emptyList();
    }

    urls.forEach(
            url -> index.addResourceToIndex(url.getPath(),
                    new ResourceInfo(url, LocalDateTime
                            .ofInstant(Instant.ofEpochMilli(bundle.getLastModified()), ZoneId.systemDefault()),
                            bundle.getBundleId()),
                    bundle));

    logger.info("Bundle '{}' scanned for resources in '{}': {} entries added to index.",
            new Object[] { bundle.getSymbolicName(), RESOURCE_ROOT, urls.size() });
}

From source file:cn.edu.zjnu.acm.judge.admin.AdminController.java

@PostMapping("/admin/contests")
public String addContest(@RequestParam(value = "title", required = false) String title,
        @RequestParam(value = "description", required = false) String description,
        @RequestParam(value = "start") @DateTimeFormat(pattern = "yyyy-M-d H:m") LocalDateTime start,
        @RequestParam("length") @Pattern(regexp = "\\d+:[0-5]?[0-9]:[0-5]?[0-9]") String length, Model model) {
    Instant startTime = start.atZone(ZoneId.systemDefault()).toInstant();
    String[] split = length.split(":", 3);
    long h = Long.parseLong(split[0]);
    int m = Integer.parseInt(split[1]);
    int s = Integer.parseInt(split[2]);
    Instant endTime = startTime.plusSeconds(h * 3600 + m * 60 + s);

    Contest contest = Contest.builder().title(title).description(description).startTime(startTime)
            .endTime(endTime).build();/*  w ww .  j a va2  s. co  m*/
    contestMapper.save(contest);

    model.addAttribute("contestId", contest.getId());
    model.addAttribute("startTime", startTime);
    model.addAttribute("endTime", endTime);

    return "admin/contests/add";
}

From source file:fr.lepellerin.ecole.service.internal.CantineServiceImpl.java

@Override
@Transactional(readOnly = true)/*from ww  w  .jav  a2s  .  c  o  m*/
public PlanningDto getDateOuvert(final YearMonth anneeMois, final Famille famille) throws TechnicalException {
    final Date startDate = Date.from(Instant.from(anneeMois.atDay(1).atStartOfDay(ZoneId.systemDefault())));
    final Date endDate = Date.from(Instant.from(anneeMois.atEndOfMonth().atStartOfDay(ZoneId.systemDefault())));

    final Activite activite = getCantineActivite();

    final LocalDateTime heureH = LocalDateTime.now();
    final List<Inscription> icts = this.ictRepository.findByActiviteAndFamille(activite, famille);

    final PlanningDto planning = new PlanningDto();

    icts.forEach(ict -> {
        planning.getHeaders().add(ict.getIndividu().getPrenom());
        final List<Consommation> consos = this.consommationRepository
                .findByFamilleInscriptionActiviteUniteEtatsPeriode(famille, activite, ict.getGroupe(),
                        Arrays.asList("reservation"), startDate, endDate);
        final List<Ouverture> ouvertures = this.ouvertureRepository.findByActiviteAndGroupeAndPeriode(activite,
                ict.getGroupe(), startDate, endDate);
        ouvertures.forEach(o -> {
            final LocalDate date = LocalDate.from(((java.sql.Date) o.getDate()).toLocalDate());
            final LocalDateTime heureResa = this.getLimiteResaCantine(date);
            final LigneDto ligne = planning.getOrCreateLigne(date);
            final CaseDto c = new CaseDto();
            c.setDate(date);
            c.setIndividu(ict.getIndividu());
            c.setActivite(o.getActivite());
            c.setUnite(o.getUnite());
            c.setReservable(heureResa.isAfter(heureH));
            final Optional<Consommation> cOpt = consos.stream().filter(conso -> {
                final LocalDate dateConso = LocalDate.from(((java.sql.Date) conso.getDate()).toLocalDate());
                return dateConso.equals(date);
            }).findAny();
            c.setReserve(cOpt.isPresent());
            ligne.getCases().add(c);
        });
    });

    return planning;
}

From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java

public static Date getDate(final LocalDate localDate) {
    Instant instant = localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
    return Date.from(instant);
}

From source file:org.ojbc.util.model.rapback.IdentificationResultSearchRequest.java

public LocalDate getReportedDateEndLocalDate() {
    return getReportedDateEndDate() == null ? null
            : reportedDateEndDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}

From source file:com.prodigious.festivities.api.bean.Festivity.java

@Override
@JsonIgnore/*from   w w  w . j a  v  a  2  s. c o  m*/
public LocalDate getStartDate() {
    if (start == null) {
        return null;
    }
    return start.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}

From source file:de.alpharogroup.user.service.UserTokensBusinessService.java

/**
 * {@inheritDoc}/*from  ww w . j  ava2  s. c  o m*/
 */
@Override
public String newAuthenticationToken(String username) {
    UserTokens userTokens = find(username);
    if (userTokens == null) {
        userTokens = merge(newUserTokens(username));
    }
    // check if expired
    Date now = Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant());
    if (userTokens.getExpiry().before(now)) {
        // expires in one year
        Date expiry = Date.from(LocalDateTime.now().plusMonths(12).atZone(ZoneId.systemDefault()).toInstant());
        // create a token
        String token = RandomExtensions.randomToken();
        userTokens.setExpiry(expiry);
        userTokens.setToken(token);
        userTokens = merge(userTokens);
    }
    return userTokens.getToken();
}

From source file:com.example.controller.user.OrderController.java

@RequestMapping(value = "/restaurants/{rest_id}/lunch/{name}/order", method = RequestMethod.POST)
public String order(@PathVariable Long rest_id, @PathVariable String name) {
    if (DataHelper.isCanCreateOrder()) {
        Restaurant restaurant = restaurantRepository.findOne(rest_id);
        if (restaurant != null) {
            Order order = orderRepository.findByCustomerLoginAndUpdatedBetween(
                    SecurityContextHolder.getContext().getAuthentication().getName(),
                    DataHelper.getYesterdayOrderTime(), DataHelper.getTodayOrderTime());
            if (order == null) {
                order = new Order();
            }/*from w  w w  .j  a  va 2  s.  co  m*/
            order.setUpdated(new Timestamp(Calendar.getInstance().getTimeInMillis()));
            order.setCustomer(userRepository
                    .findByLogin(SecurityContextHolder.getContext().getAuthentication().getName()));
            order.setLunchMenu(lunchMenuRepository.findByRestaurantAndNameAndUpdatedBetween(restaurant, name,
                    DataHelper.getYesterdayOrderTime(), DataHelper.getTodayOrderTime()));
            orderRepository.save(order);
            return "ok";
        } else
            throw new IllegalArgumentException("Restaurant not found");
    } else
        return "Can't create order, you can create order tommorow before 11:00 by"
                + ZoneId.systemDefault().getId();
}