Example usage for org.joda.time LocalDate LocalDate

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

Introduction

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

Prototype

public LocalDate() 

Source Link

Document

Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.

Usage

From source file:com.stagecents.fnd.domain.User.java

License:Open Source License

public User(CreateUserCommand command) {
    String encodedCredentials = DigestUtils.encodeCredentials(command.getRawCredentials());
    apply(new UserCreatedEvent(command.getUserId(), command.getUsername(), encodedCredentials,
            command.getStartDate(), command.getEndDate(), new LocalDate(), command.getDescription(),
            command.getEmailAddress()));
}

From source file:com.the.todo.Logic.java

License:MIT License

private void sortByDate(Map<DateCategory, List<ToDo>> todoMap, List<ToDo> todoList) {
    todoMap.clear();/*from   ww  w  .ja va2 s. c  o m*/

    Type todoType;
    LocalDate startDate;
    LocalDate endDate;
    LocalDate today = new LocalDate();
    LocalDate tomorrow = new LocalDate().plusDays(1);

    List<ToDo> todoOverdue = new ArrayList<ToDo>();
    List<ToDo> todoToday = new ArrayList<ToDo>();
    List<ToDo> todoTomorrow = new ArrayList<ToDo>();
    List<ToDo> todoUpcoming = new ArrayList<ToDo>();
    List<ToDo> todoSomeday = new ArrayList<ToDo>();

    for (ToDo todo : todoList) {
        todoType = todo.getType();
        startDate = todo.getStartDate().toLocalDate();
        endDate = todo.getEndDate().toLocalDate();

        if (todoType == Type.FLOATING) {
            todoSomeday.add(todo);
        }

        if (todoType == Type.DEADLINE) {
            if (endDate.isBefore(today)) {
                todoOverdue.add(todo);
            } else if (endDate.equals(today)) {
                todoToday.add(todo);
            } else if (endDate.equals(tomorrow)) {
                todoTomorrow.add(todo);
            }
        }

        if (todoType == Type.TIMED) {
            if (endDate.isBefore(today)) {
                todoOverdue.add(todo);
            }
            if (!today.isBefore(startDate) && !today.isAfter(endDate)) {
                todoToday.add(todo);
            }
            if (!tomorrow.isBefore(startDate) && !tomorrow.isAfter(endDate)) {
                todoTomorrow.add(todo);
            }
        }

        if (displayType == DisplayType.SEARCH) {
            if (todoType == Type.DEADLINE) {
                if (endDate.isAfter(tomorrow)) {
                    todoUpcoming.add(todo);
                }
            } else if (todoType == Type.TIMED) {
                if (endDate.isAfter(tomorrow)) {
                    todoUpcoming.add(todo);
                }
            }
        }
    }

    if (todoOverdue.size() > 0) {
        todoMap.put(DateCategory.OVERDUE, todoOverdue);
    }
    if (todoToday.size() > 0) {
        todoMap.put(DateCategory.TODAY, todoToday);
    }
    if (todoTomorrow.size() > 0) {
        todoMap.put(DateCategory.TOMORROW, todoTomorrow);
    }
    if (todoUpcoming.size() > 0) {
        todoMap.put(DateCategory.UPCOMING, todoUpcoming);
    }
    if (todoSomeday.size() > 0) {
        todoMap.put(DateCategory.SOMEDAY, todoSomeday);
    }

    for (Entry<DateCategory, List<ToDo>> entry : todoMap.entrySet()) {
        Collections.sort(entry.getValue());
    }
}

From source file:Controller.Bean.java

License:Open Source License

public void setSessionCode(String sessionCode) {
    this.sessionCode = sessionCode;
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();

    //setting a cookie to remember user on this session IF there is not already a cookie set. Cookies expire after 4 hours or so.
    Map<String, Object> cookies = ec.getRequestCookieMap();
    Cookie cookie = (Cookie) cookies.get(sessionCode);
    if (cookie == null) {
        HttpServletResponse response = (HttpServletResponse) ec.getResponse();
        String uuid = UUID.randomUUID().toString();
        cookie = new Cookie(sessionCode, uuid);
        cookie.setMaxAge(15000); // Expire time. -1 = by end of current session, 0 = immediately expire it, otherwise just the lifetime in seconds.
        response.addCookie(cookie);//from  ww  w.  j a  v a  2 s  .  c o  m
    }

    //if this is a new session code, create an entry in the two shared maps
    if (!sharedBean.getMapSessionCodesToDay().containsKey(sessionCode)) {
        sharedBean.getMapSessionCodesToDay().put(sessionCode, new LocalDate());
        sharedBean.getMapSessionCodesToIPsToGrades().put(sessionCode, new HashMap());
        sharedBean.getMapSessionCodesToIPsToTime().put(sessionCode, new HashMap());
    }

    //find and delete votes that were cast more than 5 minutes ago
    //find and delete session codes older than 1 day in the shared bean.
    findAndDeleteOldVotes(5);
    findAndDeleteOldSessionCodes();

    setTheGroupSize();

}

From source file:Controller.Bean.java

License:Open Source License

private void findAndDeleteOldSessionCodes() {
    try {//from   w w  w.  j  av  a 2 s . co m
        Iterator<Entry<String, LocalDate>> iterator = sharedBean.getMapSessionCodesToDay().entrySet()
                .iterator();
        Entry<String, LocalDate> entry;
        while (iterator.hasNext()) {
            entry = iterator.next();
            if (entry.getValue().isBefore(new LocalDate().minusDays(1))) {
                sharedBean.getMapSessionCodesToIPsToGrades().remove(entry.getKey());
                sharedBean.getMapSessionCodesToIPsToTime().remove(entry.getKey());
                iterator.remove();
            }
        }
    } catch (NullPointerException e) {
        System.out.println("NPE in findAndDeleteOldSessionCodes(): " + e.getMessage());
    }

}

From source file:Controller.BeanRNV.java

License:Open Source License

public void setSessionCode(String sessionCodeClient) {

    this.sessionCode = sessionCodeClient + "_un";
    ec = FacesContext.getCurrentInstance().getExternalContext();

    //setting a cookie to remember user on this session IF there is not already a cookie set. Cookies expire after 4 hours or so.
    Map<String, Object> cookies = ec.getRequestCookieMap();
    Cookie cookie = (Cookie) cookies.get(sessionCode);
    if (cookie == null) {
        HttpServletResponse response = (HttpServletResponse) ec.getResponse();
        String uuid = UUID.randomUUID().toString();
        cookie = new Cookie(sessionCode, uuid);
        cookie.setMaxAge(15000); // Expire time. -1 = by end of current session, 0 = immediately expire it, otherwise just the lifetime in seconds.
        response.addCookie(cookie);//  www.ja va 2 s .  co  m
    }

    //if this is a new session code, create an entry in the two shared maps
    if (!sharedBean.getMapSessionCodesToDay().containsKey(sessionCode)) {
        sharedBean.getMapSessionCodesToDay().put(sessionCode, new LocalDate());
        sharedBean.getMapSessionCodesToIPsToRangeGrades().put(sessionCode, new HashMap());
        sharedBean.getMapSessionCodesToIPsToTime().put(sessionCode, new HashMap());
    }
    findAndDeleteOldVotes(5);
    findAndDeleteOldSessionCodes();
    setTheGroupSize();

    //find and delete votes that were cast more than 5 minutes ago
    //find and delete session codes older than 1 day in the shared bean.
}

From source file:Controller.BeanUCV.java

License:Open Source License

public void setSessionCode(String sessionCodeClient) {

    this.sessionCode = sessionCodeClient + "_uc";
    ec = FacesContext.getCurrentInstance().getExternalContext();

    //setting a cookie to remember user on this session IF there is not already a cookie set. Cookies expire after 4 hours or so.
    Map<String, Object> cookies = ec.getRequestCookieMap();
    Cookie cookie = (Cookie) cookies.get(sessionCode);
    if (cookie == null) {
        HttpServletResponse response = (HttpServletResponse) ec.getResponse();
        String uuid = UUID.randomUUID().toString();
        cookie = new Cookie(sessionCode, uuid);
        cookie.setMaxAge(15000); // Expire time. -1 = by end of current session, 0 = immediately expire it, otherwise just the lifetime in seconds.
        response.addCookie(cookie);//from w w w .j a  va  2  s .co m
    }

    //if this is a new session code, create an entry in the two shared maps
    if (!sharedBean.getMapSessionCodesToDay().containsKey(sessionCode)) {
        sharedBean.getMapSessionCodesToDay().put(sessionCode, new LocalDate());
        sharedBean.getMapSessionCodesToIPsToCategories().put(sessionCode, new HashMap());
        sharedBean.getMapSessionCodesToIPsToTime().put(sessionCode, new HashMap());
    }
    findAndDeleteOldVotes(5);
    findAndDeleteOldSessionCodes();
    setTheGroupSize();

    //find and delete votes that were cast more than 5 minutes ago
    //find and delete session codes older than 1 day in the shared bean.
}

From source file:Controller.BeanUCV.java

License:Open Source License

private void findAndDeleteOldSessionCodes() {
    try {/*from   w ww .j a v a 2 s  . c  o  m*/
        Iterator<Entry<String, LocalDate>> iterator = sharedBean.getMapSessionCodesToDay().entrySet()
                .iterator();
        Entry<String, LocalDate> entry;
        while (iterator.hasNext()) {
            entry = iterator.next();
            if (entry.getValue().isBefore(new LocalDate().minusDays(1))) {
                sharedBean.getMapSessionCodesToIPsToCategories().remove(entry.getKey());
                sharedBean.getMapSessionCodesToIPsToTime().remove(entry.getKey());
                iterator.remove();
            }
        }
    } catch (NullPointerException e) {
        System.out.println("NPE in findAndDeleteOldSessionCodes(): " + e.getMessage());
    }

}

From source file:Controller.BeanUNV.java

License:Open Source License

public void setSessionCode(String sessionCodeClient) {

    this.sessionCode = sessionCodeClient + "_un";
    ec = FacesContext.getCurrentInstance().getExternalContext();

    //setting a cookie to remember user on this session IF there is not already a cookie set. Cookies expire after 4 hours or so.
    Map<String, Object> cookies = ec.getRequestCookieMap();
    Cookie cookie = (Cookie) cookies.get(sessionCode);
    if (cookie == null) {
        HttpServletResponse response = (HttpServletResponse) ec.getResponse();
        String uuid = UUID.randomUUID().toString();
        cookie = new Cookie(sessionCode, uuid);
        cookie.setMaxAge(15000); // Expire time. -1 = by end of current session, 0 = immediately expire it, otherwise just the lifetime in seconds.
        response.addCookie(cookie);//  ww  w.  j a  v  a2s.c  o m
    }

    //if this is a new session code, create an entry in the two shared maps
    if (!sharedBean.getMapSessionCodesToDay().containsKey(sessionCode)) {
        sharedBean.getMapSessionCodesToDay().put(sessionCode, new LocalDate());
        sharedBean.getMapSessionCodesToIPsToGrades().put(sessionCode, new HashMap());
        sharedBean.getMapSessionCodesToIPsToTime().put(sessionCode, new HashMap());
    }
    findAndDeleteOldVotes(5);
    findAndDeleteOldSessionCodes();
    setTheGroupSize();

    //find and delete votes that were cast more than 5 minutes ago
    //find and delete session codes older than 1 day in the shared bean.
}

From source file:cz.krtinec.birthday.dto.Zodiac.java

License:Open Source License

private static LocalDate newDate(int monthOfYear, int dayOfMonth) {
    return new LocalDate().withMonthOfYear(monthOfYear).withDayOfMonth(dayOfMonth);
}

From source file:de.appsolve.padelcampus.admin.controller.bookings.AdminBookingsReservationsController.java

@Override
public ModelAndView showIndex(HttpServletRequest request, Pageable pageable, String search) {
    String startDateStr = request.getParameter("startDate");
    String endDateStr = request.getParameter("endDate");
    LocalDate startDate = sessionUtil.getBookingListStartDate(request);
    if (startDate == null) {
        startDate = new LocalDate();
    }/*from  www.ja  v  a2  s  . c o  m*/
    if (!StringUtils.isEmpty(startDateStr)) {
        try {
            startDate = LocalDate.parse(startDateStr, DATE_HUMAN_READABLE);
        } catch (IllegalArgumentException e) {
            //ignore
        }
    }
    sessionUtil.setBookingListStartDate(request, startDate);
    LocalDate endDate = new LocalDate(startDate);
    if (!StringUtils.isEmpty(endDateStr)) {
        try {
            endDate = LocalDate.parse(endDateStr, DATE_HUMAN_READABLE);
        } catch (IllegalArgumentException e) {
            //ignore
        }
    }
    if (endDate.isBefore(startDate)) {
        endDate = new LocalDate(startDate);
    }

    DateRange dateRange = new DateRange();
    dateRange.setStartDate(startDate);
    dateRange.setEndDate(endDate);
    return getIndexView(dateRange);
}