Example usage for org.joda.time DateTime toLocalDate

List of usage examples for org.joda.time DateTime toLocalDate

Introduction

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

Prototype

public LocalDate toLocalDate() 

Source Link

Document

Converts this object to a LocalDate with the same date and chronology.

Usage

From source file:app.sunstreak.yourpisd.util.DateHelper.java

License:Open Source License

public static String daysRelative(DateTime dt) {
    while (dt.isBefore(startOfSchoolYear))
        dt = dt.plusYears(1);/*from   w w  w.j  a va2  s.c  o  m*/

    // if today
    if (dt.toLocalDate().isEqual(new LocalDate()))
        return "(today)";

    Period pd;
    if (dt.isBeforeNow())
        pd = new Interval(dt, new LocalDate().toDateTimeAtStartOfDay()).toPeriod();
    else
        pd = new Interval(new LocalDate().toDateTimeAtStartOfDay(), dt).toPeriod();
    StringBuilder sb = new StringBuilder("\n(");

    int compare = dt.compareTo(new DateTime());

    sb.append(pf.print(pd));
    // Compare to now.
    if (dt.isBeforeNow())
        sb.append(" ago)");
    else
        sb.append(" from now)");
    return sb.toString();
}

From source file:au.com.scds.chats.dom.call.Calls.java

License:Apache License

@Programmatic
public ScheduledCall createScheduledCall(final Volunteer volunteer, final Participant participant,
        final DateTime dateTime) throws Exception {
    // see if there is a Schedule for this Volunteer on this day
    if (dateTime == null) {
        throw new IllegalArgumentException("dateTime is a mandatory argument");
    }//from w  ww  .  j ava2  s.  c  o  m
    CalendarDayCallSchedule sched = null;
    if (volunteer != null) {
        List<CalendarDayCallSchedule> schedules = listDailyCallSchedulesForVolunteer(volunteer);
        for (CalendarDayCallSchedule s : schedules) {
            if (s.getCalendarDate().equals(dateTime.toLocalDate())) {
                sched = s;
                break;
            }
        }
    } else {
        throw new IllegalArgumentException("volunteer is a mandatory argument");
    }
    if (sched == null) {
        sched = createCalendarDayCallSchedule(dateTime.toLocalDate(), volunteer);
    }
    // add a new call
    // TODO should an exception be trapped here?
    ScheduledCall call = sched.scheduleCall(participant, dateTime.toLocalTime());
    // call.setParticipant(participant);
    call.setRegion(participant.getRegion());
    call.setIsCompleted(false);
    return call;
}

From source file:bean.Ouvrage.java

public String afficherDate() {
    DateTime date = new DateTime(this.getDatePublication());
    return date.toLocalDate().toString();
}

From source file:bean.Pret.java

public String afficherDatePret() {
    DateTime date = new DateTime(this.getDatePret());
    return date.toLocalDate().toString();
}

From source file:bean.Pret.java

public String afficherDateRetour() {
    DateTime date = new DateTime(this.getDateRetour());
    return date.toLocalDate().toString();
}

From source file:br.com.caelum.vraptor.converter.jodatime.LocalDateConverter.java

License:Open Source License

public LocalDate convert(String value, Class<? extends LocalDate> type, ResourceBundle bundle) {
    try {/*from  w  ww.  j a v a2 s . c  o m*/
        DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDate());
        if (out == null) {
            return null;
        }

        return out.toLocalDate();
    } catch (Exception e) {
        throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_date"), value));
    }
}

From source file:br.eti.ranieri.opcoesweb.page.PainelOpcoes.java

License:Apache License

public PainelOpcoes(String id, List<CotacaoOpcao> opcoes, DateTime atualizacao) {
    this(id, opcoes, atualizacao != null ? atualizacao.toLocalDate() : null,
            DateTimeFormat.forPattern("'Atualizado em 'HH:mm dd/MM/yyyy").withLocale(ptBR).print(atualizacao));
}

From source file:cl.usach.managedbeans.TrabajoSemanalManagedBean.java

public List<Semana> buscarSemanas(Date datei, Date datef) {
    DateTime fechai = new DateTime(datei);
    DateTime fechaf = new DateTime(datef);
    LocalDate lunesI = fechai.toLocalDate().withDayOfWeek(DateTimeConstants.MONDAY);
    LocalDate domingoF = fechaf.toLocalDate().withDayOfWeek(DateTimeConstants.SUNDAY);

    List<Semana> semanas = new ArrayList<>();
    DateTime i = lunesI.toDateTimeAtStartOfDay();
    while (i.isBefore(domingoF.toDateTimeAtStartOfDay())) {
        DateTime domingoi = i.toLocalDate().withDayOfWeek(DateTimeConstants.SUNDAY).toDateTimeAtStartOfDay();
        domingoi = domingoi.plusHours(23).plusMinutes(59).plusSeconds(59);
        semanas.add(new Semana(i.toDate(), domingoi.toDate()));
        i = i.plusWeeks(1);//from  w  w w  .j  av  a 2s  . co m
    }
    return semanas;
}

From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemDateTime.java

License:Open Source License

public CosemDateTime(final DateTime dateTime) {
    this(dateTime.toLocalDate(), dateTime.toLocalTime(), determineDeviation(dateTime),
            determineClockStatus(dateTime));
}

From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemDateTimeDto.java

License:Open Source License

public CosemDateTimeDto(final DateTime dateTime) {
    this(dateTime.toLocalDate(), dateTime.toLocalTime(), determineDeviation(dateTime),
            determineClockStatus(dateTime));
}