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(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:com.mns.mojoinvest.server.servlet.params.ParameterParser.java

License:Open Source License

public LocalDate getLocalDateParameter(String name) throws ParameterNotFoundException {
    return new LocalDate(getStringParameter(name));
}

From source file:com.mycollab.core.utils.DateTimeUtils.java

License:Open Source License

/**
 * Trim hour-minute-second of date instance value to zero.
 *
 * @param value/*from www.  j  a v a2  s .  c  o  m*/
 * @return
 */
public static Date trimHMSOfDate(Date value) {
    return new LocalDate(value).toDate();
}

From source file:com.mycollab.core.utils.DateTimeUtils.java

License:Open Source License

public static String getPrettyDurationValue(Date date, Locale locale) {
    Period period = new Period(new LocalDate(date), LocalDate.now());
    PeriodFormatter formatter = PeriodFormat.wordBased(locale);
    return formatter.print(period);
}

From source file:com.mycollab.module.project.view.task.TaskEditFormFieldFactory.java

License:Open Source License

private void calculateDurationBaseOnStartAndEndDates() {
    DateTimeOptionField startDateField = (DateTimeOptionField) fieldGroup.getField(Task.Field.startdate.name());
    DateTimeOptionField endDateField = (DateTimeOptionField) fieldGroup.getField(Task.Field.enddate.name());
    TextField durationField = (TextField) fieldGroup.getField(Task.Field.duration.name());
    Date startDate = null, endDate = null;
    if (startDateField != null) {
        startDate = startDateField.getValue();
    }// w  w w.  j  av a 2  s. co  m
    if (endDateField != null) {
        endDate = endDateField.getValue();
    }
    if (startDate != null && endDate != null && startDate.before(endDate) && durationField != null) {
        LocalDate jodaStartDate = new LocalDate(startDate);
        LocalDate jodaEndDate = new LocalDate(endDate);
        int durationInDays = BusinessDayTimeUtils.duration(jodaStartDate, jodaEndDate);
        durationField.setValue(durationInDays + " d");
    }
}

From source file:com.mycollab.module.project.view.ticket.CreatedDateOrderComponent.java

License:Open Source License

@Override
public void insertTickets(List<ProjectTicket> tickets) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getLongDateFormat())
            .withLocale(UserUIContext.getUserLocale());
    for (ProjectTicket ticket : tickets) {
        if (ticket.getCreatedTime() != null) {
            Date createdDate = ticket.getCreatedTime();
            DateTime jodaTime = new DateTime(createdDate, DateTimeZone.UTC);
            DateTime monDay = jodaTime.dayOfWeek().withMinimumValue();
            String monDayStr = formatter.print(monDay);
            Long time = new LocalDate(monDay).toDate().getTime();
            if (createdDateAvailables.containsKey(time)) {
                DefaultTicketGroupComponent groupComponent = createdDateAvailables.get(time);
                groupComponent.insertTicket(ticket);
            } else {
                DateTime maxValue = monDay.dayOfWeek().withMaximumValue();
                String sundayStr = formatter.print(maxValue);
                String titleValue = String.format("%s - %s", monDayStr, sundayStr);

                DefaultTicketGroupComponent groupComponent = new DefaultTicketGroupComponent(titleValue);
                createdDateAvailables.put(time, groupComponent);
                addComponent(groupComponent);
                groupComponent.insertTicket(ticket);
            }//from  w  w  w  . j  a v a  2 s. co  m
        } else {
            if (unspecifiedTasks == null) {
                unspecifiedTasks = new DefaultTicketGroupComponent(
                        UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
                addComponent(unspecifiedTasks, 0);
            }
            unspecifiedTasks.insertTicket(ticket);
        }
    }
}

From source file:com.mycollab.module.project.view.ticket.DueDateOrderComponent.java

License:Open Source License

@Override
public void insertTickets(List<ProjectTicket> tickets) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getLongDateFormat())
            .withLocale(UserUIContext.getUserLocale());
    for (ProjectTicket ticket : tickets) {
        if (ticket.getDueDate() != null) {
            Date dueDate = ticket.getDueDate();
            DateTime jodaTime = new DateTime(dueDate, DateTimeZone.UTC);
            DateTime monDay = jodaTime.dayOfWeek().withMinimumValue();
            String monDayStr = formatter.print(monDay);
            Long time = new LocalDate(monDay).toDate().getTime();
            if (dueDateAvailables.containsKey(time)) {
                DefaultTicketGroupComponent groupComponent = dueDateAvailables.get(time);
                groupComponent.insertTicket(ticket);
            } else {
                DateTime maxValue = monDay.dayOfWeek().withMaximumValue();
                String sundayStr = formatter.print(maxValue);
                String titleValue = String.format("%s - %s", monDayStr, sundayStr);

                DefaultTicketGroupComponent groupComponent = new DefaultTicketGroupComponent(titleValue);
                dueDateAvailables.put(time, groupComponent);
                addComponent(groupComponent);
                groupComponent.insertTicket(ticket);
            }//  ww  w .  ja  v a 2 s. co m
        } else {
            if (unspecifiedTasks == null) {
                unspecifiedTasks = new DefaultTicketGroupComponent(
                        UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
                addComponent(unspecifiedTasks);
            }
            unspecifiedTasks.insertTicket(ticket);
        }
    }
}

From source file:com.mycollab.module.project.view.ticket.StartDateOrderComponent.java

License:Open Source License

@Override
public void insertTickets(List<ProjectTicket> tickets) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getLongDateFormat())
            .withLocale(UserUIContext.getUserLocale());
    for (ProjectTicket task : tickets) {
        if (task.getStartDate() != null) {
            Date startDate = task.getStartDate();
            DateTime jodaTime = new DateTime(startDate, DateTimeZone.UTC);
            DateTime monDay = jodaTime.dayOfWeek().withMinimumValue();
            String monDayStr = formatter.print(monDay);
            Long time = new LocalDate(monDay).toDate().getTime();
            if (startDateAvailables.containsKey(time)) {
                DefaultTicketGroupComponent groupComponent = startDateAvailables.get(time);
                groupComponent.insertTicket(task);
            } else {
                DateTime maxValue = monDay.dayOfWeek().withMaximumValue();
                String sundayStr = formatter.print(maxValue);
                String titleValue = String.format("%s - %s", monDayStr, sundayStr);

                DefaultTicketGroupComponent groupComponent = new DefaultTicketGroupComponent(titleValue);
                startDateAvailables.put(time, groupComponent);
                addComponent(groupComponent);
                groupComponent.insertTicket(task);
            }/* w  w  w . ja v  a 2  s . co  m*/
        } else {
            if (unspecifiedTasks == null) {
                unspecifiedTasks = new DefaultTicketGroupComponent(
                        UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
                addComponent(unspecifiedTasks, 0);
            }
            unspecifiedTasks.insertTicket(task);
        }
    }
}

From source file:com.mycollab.vaadin.web.ui.field.DateTimeOptionField.java

License:Open Source License

private Date getDateValue() {
    Date selectDate = popupDateField.getValue();
    if (selectDate == null) {
        return null;
    }/*from  w  w  w. ja v  a2 s. c  o  m*/

    DateTime jodaSelectDate = new DateTime(selectDate)
            .toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone()));
    Date baseDate = new LocalDate(jodaSelectDate).toDate();
    if (hideTimeOption) {
        return new LocalDateTime(baseDate).toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone()))
                .toDate();
    } else {
        Integer hour = (hourPickerComboBox.getValue() != null)
                ? Integer.parseInt((String) hourPickerComboBox.getValue())
                : 0;
        Integer minus = (minutePickerComboBox.getValue() != null)
                ? Integer.parseInt((String) minutePickerComboBox.getValue())
                : 0;
        String timeFormat = (timeFormatComboBox.getValue() != null) ? (String) timeFormatComboBox.getValue()
                : "AM";
        long milliseconds = calculateMilliSeconds(hour, minus, timeFormat);
        DateTime jodaTime = new DateTime(baseDate).plus(new Duration(milliseconds));
        return new LocalDateTime(jodaTime.getMillis())
                .toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone())).toDate();
    }
}

From source file:com.mycompany.login.mb.DateBean.java

public LocalDate getDateInicial() {
    Date date = new Date();
    LocalDate datainicial = new LocalDate(date);
    return datainicial;

}

From source file:com.mycompany.login.mb.DateBean.java

public LocalDate getDateFinal() {
    Date date = new Date();
    LocalDate datafinal = new LocalDate(date);
    return datafinal;
}