Java Code Examples for org.joda.time.DateTime#dayOfWeek()

The following examples show how to use org.joda.time.DateTime#dayOfWeek() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TodayWidgetProvider.java    From ETSMobile-Android2 with Apache License 2.0 6 votes vote down vote up
private void setUpTodayDateTv(Context context, RemoteViews views) {

        if (mUserLoggedIn) {
            DateTime dateActuelle = dateTime;
            DateTime.Property pDoW = dateActuelle.dayOfWeek();
            DateTime.Property pDoM = dateActuelle.dayOfMonth();
            DateTime.Property pMoY = dateActuelle.monthOfYear();
            Locale locale = context.getResources().getConfiguration().locale;
            String dateActuelleStr = context.getString(R.string.horaire, pDoW.getAsText(locale),
                    pDoM.getAsText(locale), pMoY.getAsText(locale));
            views.setViewVisibility(todayNameTvId, View.GONE);
            views.setTextViewText(todayNameTvId, dateActuelleStr);
            views.setViewVisibility(todayNameTvId, View.VISIBLE);
        } else {
            views.setViewVisibility(todayNameTvId, View.GONE);
        }
    }
 
Example 2
Source File: TodayWidgetConfigureActivity.java    From ETSMobile-Android2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    int textColor = Integer.parseInt(mTextColorSpinner.getSelectedItem().toString());
    DateTime dateActuelle = new DateTime();
    DateTime.Property pDoW = dateActuelle.dayOfWeek();
    DateTime.Property pDoM = dateActuelle.dayOfMonth();
    DateTime.Property pMoY = dateActuelle.monthOfYear();
    Locale locale = TodayWidgetConfigureActivity.this.getResources().getConfiguration()
            .locale;
    String dateActuelleStr = TodayWidgetConfigureActivity.this.getString(R.string.horaire,
            pDoW.getAsText(locale),
            pDoM.getAsText(locale), pMoY.getAsText(locale));

    mWidgetTodaysNameTv.setText(dateActuelleStr);
    mWidgetTodaysNameTv.setTextColor(textColor);

    prevBtn.setColorFilter(textColor);
    nextBtn.setColorFilter(textColor);

    syncBtn.setColorFilter(textColor);
    syncBtn.setBackgroundColor(Color.TRANSPARENT);
    syncBtn.setVisibility(View.VISIBLE);
}
 
Example 3
Source File: DatetimeUtil.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Gets the start datetime.
 *
 * @param curr the curr
 * @param type the type
 * @return the start datetime
 */
protected static DateTime startDateTime(DateTime curr, DateType type) {
    DateTime result = curr;
    Property pr = null;
    if (DateType.YEAR.equals(type)) {
        pr = curr.dayOfYear();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.MONTH.equals(type)) {
        pr = curr.dayOfMonth();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.WEEK.equals(type)) {
        pr = curr.dayOfWeek();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.DAY.equals(type)) {
        pr = curr.hourOfDay();
        result = pr.withMinimumValue().withTimeAtStartOfDay();
    } else if (DateType.HOUR.equals(type)) {
        pr = curr.minuteOfHour();
        result = pr.withMinimumValue().withMinuteOfHour(0).withSecondOfMinute(0)
            .withMillisOfSecond(0);
    } else if (DateType.MINUTE.equals(type)) {
        pr = curr.secondOfMinute();
        result = pr.withMinimumValue().withSecondOfMinute(0).withMillisOfSecond(0);
    } else if (DateType.SECOND.equals(type)) {
        pr = curr.millisOfSecond();
        result = pr.withMinimumValue().withMillisOfSecond(0);
    }
    return result;
}
 
Example 4
Source File: SeanceAdapter.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
public void setItemList(List<Seances> itemListSeance, List<Event> itemListEvent) {

        listSeances = new ArrayList<>();
        ArrayList<IHoraireRows> listRowItems = new ArrayList<IHoraireRows>();
        String tempDate = "";
        DateTime today = new DateTime();

        listRowItems.addAll(itemListEvent);
        listRowItems.addAll(itemListSeance);

        Collections.sort(listRowItems, new HoraireComparator());

        for(IHoraireRows rows : listRowItems) {

            DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
            DateTime seanceDay = formatter.parseDateTime(rows.getDateDebut().substring(0, 10));

//            if(today.isAfter(seanceDay) && !DateUtils.isToday(seanceDay.getMillis()) ) {
//                continue;
//            }

            if(!rows.getDateDebut().substring(0,10).equals(tempDate)) {

                tempDate = rows.getDateDebut().substring(0,10);

                DateTime.Property pDoW = seanceDay.dayOfWeek();
                DateTime.Property pDoM = seanceDay.dayOfMonth();
                DateTime.Property pMoY = seanceDay.monthOfYear();

                this.listSeances.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE, context.getString(R.string.date_text, pDoW.getAsText(Locale.getDefault()), pDoM.get(), pMoY.getAsText(Locale.getDefault()))));
            }

            if(rows.getClass().equals(Event.class)){
                this.listSeances.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_ETS_EVENT, rows));
            } else if(rows.getClass().equals(Seances.class)){
                this.listSeances.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_SEANCE, rows));
            }
        }

    }
 
Example 5
Source File: SeancesPagerAdapter.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int row, int col) {
    final View view = inflater.inflate(R.layout.item_seance_gridviewpager, container, false);

    final TextView tvDate = (TextView) view.findViewById(R.id.tv_date);
    final TextView tvStartHour = (TextView) view.findViewById(R.id.tv_start_hour);
    final TextView tvStartMinute = (TextView) view.findViewById(R.id.tv_start_minute);
    final TextView tvEndHour = (TextView) view.findViewById(R.id.tv_end_hour);
    final TextView tvEndMinute = (TextView) view.findViewById(R.id.tv_end_minute);
    final TextView tvActivityName = (TextView) view.findViewById(R.id.tv_activity_name);
    final TextView tvCourseGroupId = (TextView) view.findViewById(R.id.tv_course_group_id);
    final TextView tvLocal = (TextView) view.findViewById(R.id.tv_local);
    final ProgressLayout progressLayout = (ProgressLayout) view.findViewById(R.id.progressLayout);

    Seances seance = mSeances.get(col);

    DateTime startDateTime = DateTime.parse(seance.dateDebut);
    DateTime endDateTime = DateTime.parse(seance.dateFin);

    String startHour = String.format("%d", startDateTime.getHourOfDay());
    String startMinute = String.format("%02d", startDateTime.getMinuteOfHour());
    String endHour = String.format("%d", endDateTime.getHourOfDay());
    String endMinute = String.format("%02d", endDateTime.getMinuteOfHour());

    DateTime dateTime = new DateTime();

    if (ShapeWear.getShape() == ShapeWear.ScreenShape.RECTANGLE) {
        progressLayout.setSquareDisplay(true);
    } else {
        progressLayout.setSquareDisplay(false);
    }

    //currently during the course
    if (dateTime.isBefore(endDateTime) && dateTime.isAfter(startDateTime)) {
        progressLayout.setBoundsCourse(startDateTime, endDateTime);
        progressLayout.setAutoProgress(true);
        progressLayout.start();
    } else {
        progressLayout.setCurrentProgress(100);
    }


    DateTime.Property pDoW = startDateTime.dayOfWeek();
    DateTime.Property pDoM = startDateTime.dayOfMonth();
    DateTime.Property pMoY = startDateTime.monthOfYear();

    Locale currentLocale = mContext.getResources().getConfiguration().locale;

    tvDate.setText(
            mContext.getString(
                    R.string.horaire, pDoW.getAsText(currentLocale),
                    "" + pDoM.get(),
                    pMoY.getAsText(currentLocale)));


    tvStartHour.setText(startHour);
    tvStartMinute.setText(startMinute);
    tvEndHour.setText(endHour);
    tvEndMinute.setText(endMinute);
    tvActivityName.setText(seance.nomActivite);
    tvCourseGroupId.setText(seance.coursGroupe);
    tvLocal.setText(seance.local);

    container.addView(view);
    return view;
}
 
Example 6
Source File: TodayFragment.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
@Override
void updateUI() {
    if (isAdded()) {
        dateTime = new DateTime();

        DateTime.Property pDoW = dateTime.dayOfWeek();
        DateTime.Property pDoM = dateTime.dayOfMonth();
        DateTime.Property pMoY = dateTime.monthOfYear();

        Locale locale = getResources().getConfiguration().locale;

        todaysTv.setText(getActivity().getString(R.string.horaire, pDoW.getAsText(locale), pDoM.getAsText(locale), pMoY.getAsText(locale)));
        databaseHelper = new DatabaseHelper(getActivity());
        listSeances = new ArrayList<Seances>();
        events = new ArrayList<Event>();
        try {
            SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd", getResources().getConfiguration().locale);
            listSeances = (ArrayList<Seances>) databaseHelper.getDao(Seances.class).queryBuilder().where().like("dateDebut", seancesFormatter.format(dateTime.toDate()) + "%").query();
            Collections.sort(listSeances, new SeanceComparator());
            events = (ArrayList<Event>) databaseHelper.getDao(Event.class).queryBuilder().where().like("startDate", seancesFormatter.format(dateTime.toDate()) + "%").query();

        } catch (Exception e) {
            e.printStackTrace();
        }

        ArrayList<TodayDataRowItem> dataRowItems = new ArrayList<TodayDataRowItem>();
        if (!events.isEmpty()) {
            dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_TITLE_EVENT));
            for (Event event : events) {
                dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_EVENT, event));
            }
        }

        dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE));
        if (listSeances.isEmpty()) {
            tvNoCourses.setVisibility(View.VISIBLE);
        } else {
            for (Seances seances : listSeances) {
                dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_SEANCE, seances));
            }
            tvNoCourses.setVisibility(View.GONE);
        }
        adapter = new TodayAdapter(getActivity(), dataRowItems);
        todaysList.setAdapter(adapter);

    }
}
 
Example 7
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate1() {
    DateTime dt = new DateTime(1945, 11, 12, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(14, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(64, dt.getYearOfCentury());
    assertEquals(1364, dt.getYearOfEra());
    
    assertEquals(1364, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1365, 12, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1365, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    assertEquals(new DateTime(1364, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addWrapFieldToCopy(1));
    
    assertEquals(6, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.MONDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(6 * 30 + 5 * 29 + 6, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(354, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 8
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate2() {
    DateTime dt = new DateTime(2005, 11, 26, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(15, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(26, dt.getYearOfCentury());
    assertEquals(1426, dt.getYearOfEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.SATURDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(5 * 30 + 4 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 9
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate3() {
    DateTime dt = new DateTime(1426, 12, 24, 0, 0, 0, 0, ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.TUESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(6 * 30 + 5 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 10
Source File: TestCopticChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(COPTIC_UTC);
    assertEquals(CopticChronology.AM, dt.getEra());
    assertEquals(18, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(20, dt.getYearOfCentury());
    assertEquals(1720, dt.getYearOfEra());
    
    assertEquals(1720, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1721, 10, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1721, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1720, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 11
Source File: TestEthiopicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(ETHIOPIC_UTC);
    assertEquals(EthiopicChronology.EE, dt.getEra());
    assertEquals(20, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(96, dt.getYearOfCentury());
    assertEquals(1996, dt.getYearOfEra());
    
    assertEquals(1996, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1997, 10, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1997, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1996, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 12
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate1() {
    DateTime dt = new DateTime(1945, 11, 12, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(14, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(64, dt.getYearOfCentury());
    assertEquals(1364, dt.getYearOfEra());
    
    assertEquals(1364, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1365, 12, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1365, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    assertEquals(new DateTime(1364, 1, 6, 0, 0, 0, 0, ISLAMIC_UTC), fld.addWrapFieldToCopy(1));
    
    assertEquals(6, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.MONDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(6 * 30 + 5 * 29 + 6, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(354, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1364, 12, 7, 0, 0, 0, 0, ISLAMIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 13
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate2() {
    DateTime dt = new DateTime(2005, 11, 26, 0, 0, 0, 0, ISO_UTC);
    dt = dt.withChronology(ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    assertEquals(15, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(26, dt.getYearOfCentury());
    assertEquals(1426, dt.getYearOfEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(29, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.SATURDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(5 * 30 + 4 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 14
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate3() {
    DateTime dt = new DateTime(1426, 12, 24, 0, 0, 0, 0, ISLAMIC_UTC);
    assertEquals(IslamicChronology.AH, dt.getEra());
    
    assertEquals(1426, dt.getYear());
    Property fld = dt.year();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    
    assertEquals(12, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(true, fld.isLeap());
    assertEquals(1, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(12, fld.getMaximumValue());
    assertEquals(12, fld.getMaximumValueOverall());
    
    assertEquals(24, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    
    assertEquals(DateTimeConstants.TUESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    
    assertEquals(6 * 30 + 5 * 29 + 24, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(355, fld.getMaximumValue());
    assertEquals(355, fld.getMaximumValueOverall());
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 15
Source File: TestCopticChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(COPTIC_UTC);
    assertEquals(CopticChronology.AM, dt.getEra());
    assertEquals(18, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(20, dt.getYearOfCentury());
    assertEquals(1720, dt.getYearOfEra());
    
    assertEquals(1720, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1721, 10, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1721, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1720, 1, 2, 0, 0, 0, 0, COPTIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1720, 10, 3, 0, 0, 0, 0, COPTIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}
 
Example 16
Source File: TestEthiopicChronology.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testSampleDate() {
    DateTime dt = new DateTime(2004, 6, 9, 0, 0, 0, 0, ISO_UTC).withChronology(ETHIOPIC_UTC);
    assertEquals(EthiopicChronology.EE, dt.getEra());
    assertEquals(20, dt.getCenturyOfEra());  // TODO confirm
    assertEquals(96, dt.getYearOfCentury());
    assertEquals(1996, dt.getYearOfEra());
    
    assertEquals(1996, dt.getYear());
    Property fld = dt.year();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(new DateTime(1997, 10, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(10, dt.getMonthOfYear());
    fld = dt.monthOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(DurationFieldType.days(), fld.getLeapDurationField().getType());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(13, fld.getMaximumValue());
    assertEquals(13, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1997, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(4));
    assertEquals(new DateTime(1996, 1, 2, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addWrapFieldToCopy(4));
    
    assertEquals(2, dt.getDayOfMonth());
    fld = dt.dayOfMonth();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(30, fld.getMaximumValue());
    assertEquals(30, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(DateTimeConstants.WEDNESDAY, dt.getDayOfWeek());
    fld = dt.dayOfWeek();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(7, fld.getMaximumValue());
    assertEquals(7, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(9 * 30 + 2, dt.getDayOfYear());
    fld = dt.dayOfYear();
    assertEquals(false, fld.isLeap());
    assertEquals(0, fld.getLeapAmount());
    assertEquals(null, fld.getLeapDurationField());
    assertEquals(1, fld.getMinimumValue());
    assertEquals(1, fld.getMinimumValueOverall());
    assertEquals(365, fld.getMaximumValue());
    assertEquals(366, fld.getMaximumValueOverall());
    assertEquals(new DateTime(1996, 10, 3, 0, 0, 0, 0, ETHIOPIC_UTC), fld.addToCopy(1));
    
    assertEquals(0, dt.getHourOfDay());
    assertEquals(0, dt.getMinuteOfHour());
    assertEquals(0, dt.getSecondOfMinute());
    assertEquals(0, dt.getMillisOfSecond());
}