Example usage for org.joda.time DateMidnight getWeekOfWeekyear

List of usage examples for org.joda.time DateMidnight getWeekOfWeekyear

Introduction

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

Prototype

public int getWeekOfWeekyear() 

Source Link

Document

Get the week of weekyear field value.

Usage

From source file:dk.teachus.backend.domain.impl.PeriodsImpl.java

License:Apache License

public List<DatePeriod> generateDatesForWeek(DateMidnight startDate) {
    List<DatePeriod> dates = new ArrayList<DatePeriod>();
    DateMidnight sd = startDate.withDayOfWeek(DateTimeConstants.MONDAY);
    int week = sd.getWeekOfWeekyear();

    while (week == sd.getWeekOfWeekyear()) {
        DatePeriod datePeriod = null;//from ww w  .java2s  .c om
        for (Period period : getValidPeriods()) {
            // Check if this period can handle the date at all
            if (period.dateIntervalContains(sd)) {
                DateMidnight date = period.generateDate(sd);
                if (date != null) {
                    if (datePeriod == null) {
                        datePeriod = new DatePeriodImpl(date);
                        dates.add(datePeriod);
                    }

                    datePeriod.addPeriod(period);
                }
            }
        }

        sd = sd.plusDays(1);
    }

    Collections.sort(dates, new Comparator<DatePeriod>() {
        public int compare(DatePeriod o1, DatePeriod o2) {
            return o1.getDate().compareTo(o2.getDate());
        }
    });

    return dates;
}

From source file:org.wicketstuff.ddcalendar.CalendarWeek.java

License:Apache License

public CalendarWeek() {
    DateMidnight now = new DateMidnight();
    this.year = now.getYear();
    this.week = now.getWeekOfWeekyear();
}