Example usage for org.joda.time LocalDate now

List of usage examples for org.joda.time LocalDate now

Introduction

In this page you can find the example usage for org.joda.time LocalDate now.

Prototype

public static LocalDate now() 

Source Link

Document

Obtains a LocalDate set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:it.cineca.pst.huborcid.security.CustomPersistentRememberMeServices.java

License:Open Source License

/**
 * Validate the token and return it./*from  w  w  w.j  a  va2  s. c o  m*/
 */
private PersistentToken getPersistentToken(String[] cookieTokens) {
    if (cookieTokens.length != 2) {
        throw new InvalidCookieException("Cookie token did not contain " + 2 + " tokens, but contained '"
                + Arrays.asList(cookieTokens) + "'");
    }
    String presentedSeries = cookieTokens[0];
    String presentedToken = cookieTokens[1];
    PersistentToken token = persistentTokenRepository.findOne(presentedSeries);

    if (token == null) {
        // No series match, so we can't authenticate using this cookie
        throw new RememberMeAuthenticationException(
                "No persistent token found for series id: " + presentedSeries);
    }

    // We have a match for this user/series combination
    log.info("presentedToken={} / tokenValue={}", presentedToken, token.getTokenValue());
    if (!presentedToken.equals(token.getTokenValue())) {
        // Token doesn't match series value. Delete this session and throw an exception.
        persistentTokenRepository.delete(token);
        throw new CookieTheftException(
                "Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack.");
    }

    if (token.getTokenDate().plusDays(TOKEN_VALIDITY_DAYS).isBefore(LocalDate.now())) {
        persistentTokenRepository.delete(token);
        throw new RememberMeAuthenticationException("Remember-me login has expired");
    }
    return token;
}

From source file:it.newfammulfin.api.EntryResource.java

@GET
@Path("template")
public Response template(@PathParam("groupId") @NotNull Long groupId) {
    Group group = (Group) requestContext.getProperty(GroupRetrieverRequestFilter.GROUP);
    Key<RegisteredUser> userKey = Key.create(RegisteredUser.class,
            securityContext.getUserPrincipal().getName());
    Entry entry = new Entry();
    entry.setAmount(Money.of(group.getDefaultCurrencyUnit(), 2.20));
    entry.setDate(LocalDate.now());
    entry.setPayee("Pub");
    entry.setDescription("Beer");
    entry.getTags().add("Fun");
    entry.getByShares().put(userKey, entry.getAmount().getAmount());
    for (Key<RegisteredUser> otherSserKey : group.getUsersMap().keySet()) {
        entry.getForShares().put(otherSserKey, BigDecimal.ZERO);
    }//from   w w  w  .ja v  a2  s.c  o m
    checkAndBalanceZeroShares(entry.getForShares(), entry.getAmount().getAmount());
    return Response.ok(entry).build();
}

From source file:julian.lylly.model.OrganizerImpl.java

private Pair<Duration, Duration> getBudget(Prospect prospect) {
    return prospect.getNextBudget(LocalDate.now(), //FIXME: maybe buggy at midnight
            taskOrg.getInvestedTime(prospect.getStart(), LocalDate.now(), prospect.getTag()));
}

From source file:julian.lylly.model.Prospect.java

public boolean isActive() {
    LocalDate now = LocalDate.now();
    return !now.isBefore(start) && now.isBefore(end);
}

From source file:julian.lylly.model.Prospect.java

public boolean isBeforeStart() {
    return LocalDate.now().isBefore(start);
}

From source file:julian.lylly.model.Prospect.java

public boolean isOver() {
    return LocalDate.now().isAfter(end);
}

From source file:julian.lylly.model.ProspectOrganizerImpl.java

/**
 * returns prospects that have not yet started
 * @return/*  w  ww. jav a 2  s  .  c o  m*/
 */
@Override
public List<Prospect> getFutureProspects() {
    List<Prospect> res = new ArrayList<>();
    for (Prospect p : enabled) {
        if (LocalDate.now().isAfter(p.getEnd())) {
            res.add(p);
        }
    }
    return res;
}

From source file:julian.lylly.model.Task.java

public boolean isRecent() {
    return done == null || !new LocalDate(done).isBefore(LocalDate.now());
}

From source file:julian.lylly.model.TaskOrganizerImpl.java

@Override
public Duration getTodaysInvTime(Tag tag) {
    LocalDate today = LocalDate.now();
    return getInvestedTime(today, today.plusDays(1), tag);
}

From source file:li.klass.fhem.util.DateFormatUtil.java

License:Open Source License

public static String formatTime(String input) {
    try {/*w w  w  .j  av a 2  s  .  c  om*/
        if (input.equalsIgnoreCase("Initialized")) {
            return null;
        }
        DateTime dateTime = FHEM_DATE_FORMAT.parseDateTime(input);
        if (dateTime.toLocalDate().equals(LocalDate.now())) {
            return ANDFHEM_TIME_FORMAT.print(dateTime);
        } else {
            return ANDFHEM_DATE_FORMAT.print(dateTime);
        }
    } catch (Exception e) {
        LOGGER.error("cannot format " + input, e);
        return input;
    }
}