Example usage for org.joda.time DateTime getYear

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:com.tmathmeyer.sentinel.ui.views.month.MonthItem.java

License:Open Source License

/**
 * Check if end date of event is after the specified day
 * //ww w.j  a v a2 s. c o  m
 * @param currentDay day to compare event time with
 * @param eventEnd event time
 * @return boolean determining whether the event end date is after current
 *         day
 */
private boolean isEndAfterCurrent(DateTime currentDay, DateTime eventEnd) {
    if (eventEnd.getYear() > currentDay.getYear())// if the year is less
        // than its always true
        return true;
    else if (eventEnd.getYear() < currentDay.getYear())
        return false;
    else if (eventEnd.getDayOfYear() > currentDay.getDayOfYear())// year is
        // the
        // same, so
        // only day
        // matters
        return true;
    return false;
}

From source file:com.tmathmeyer.sentinel.ui.views.year.YearCalendar.java

License:Open Source License

/**
 * /*from w ww.j  a va 2 s .  co m*/
 * @param dt any date time
 * @return the date time that corresponds to january first of the year of
 *         the date time provided
 */
private MutableDateTime getStartOfYearCalendar(DateTime dt) {
    MutableDateTime jan1 = new MutableDateTime(new DateTime(dt.getYear(), 1, 1, 1, 1));
    jan1.addDays(0 - (jan1.getDayOfWeek()));
    return jan1;
}

From source file:com.todoroo.astrid.repeats.RepeatControlSet.java

License:Open Source License

private void repeatUntilClick() {
    MyDatePickerDialog dialog = new MyDatePickerDialog();
    DateTime initial = newDateTime();
    dialog.initialize(new DatePickerDialog.OnDateSetListener() {
        @Override//from w  w w.j a  va 2s .com
        public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
            setRepeatUntilValue(new DateTime(year, month + 1, day, 0, 0, 0, 0).getMillis());
        }
    }, initial.getYear(), initial.getMonthOfYear() - 1, initial.getDayOfMonth(), false);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            setRepeatUntilValue(repeatUntilValue);
        }
    });
    dialog.show(activity.getSupportFragmentManager(), FRAG_TAG_REPEAT_UNTIL);
}

From source file:com.todoroo.astrid.ui.ReminderControlSet.java

License:Open Source License

private String getDisplayString(long forDate) {
    DateTime dateTime = newDateTime(forDate);
    Date d = dateTime.toDate();/*from   w  w w  .  j av a  2  s. c  o m*/
    return (dateTime.getYear() == newDateTime().getYear() ? DateUtilities.getLongDateStringHideYear(d)
            : DateUtilities.getLongDateString(d)) + ", " + DateUtilities.getTimeString(activity, d);
}

From source file:com.toedter.jcalendar.core.DateChooser.java

License:Open Source License

/**
 * Constructs an instance from a given DateTime.
 * //from   w  ww. java  2 s. c  o  m
 * @param calendar
 *            the initializing DateTime
 */
public DateChooser(DateTime dateTime) {
    // normalize to year/month/date only
    this.dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), 0, 0,
            0, 0);
    dayCells = new ArrayList<IDayCell>(42);
    for (int i = 0; i < 42; i++) {
        DayCell dayCell = new DayCell();
        dayCells.add(dayCell);
    }

    locale = Locale.getDefault();
    computeWeekdayNames();
    computeDayCellValues();
}

From source file:com.turn.sorcerer.pipeline.impl.CronPipeline.java

License:Open Source License

private int getIterationNumber(DateTime dt, int dayIterNo) {
    int year = dt.getYear();
    int month = dt.getMonthOfYear();
    int day = dt.getDayOfMonth();

    return (((year % 100) * 10000) + (month * 100) + day) * 10000 + dayIterNo;
}

From source file:com.turn.sorcerer.pipeline.impl.CronPipeline.java

License:Open Source License

private int getLastIterNoForDate(DateTime dt) {
    int iterNo = 0;
    DateTime _next = new DateTime().withYear(dt.getYear()).withDayOfYear(dt.getDayOfYear()).withHourOfDay(0)
            .withMinuteOfHour(0).withSecondOfMinute(0);

    while (_next.getDayOfMonth() == dt.getDayOfMonth()) {
        _next = cronExp.getNextTimeAfter(_next);
        iterNo++;//from  w w  w  .  j  a  v  a 2 s  .c  o  m
    }

    return iterNo;
}

From source file:com.turn.sorcerer.pipeline.impl.CronPipeline.java

License:Open Source License

private int getDayIterNoForDateTime(DateTime dt) {
    int iterNo = 0;
    DateTime _next = new DateTime().withYear(dt.getYear()).withDayOfYear(dt.getDayOfYear()).withHourOfDay(0)
            .withMinuteOfHour(0).withSecondOfMinute(0);

    while (_next.isBefore(dt)) {
        _next = cronExp.getNextTimeAfter(_next);
        iterNo++;//from  w  ww  . j a  v  a2 s  . c  o  m
    }

    return iterNo;
}

From source file:com.tysanclan.site.projectewok.TysanPage.java

License:Open Source License

public boolean isAprilFoolsDay(int year) {
    final DateTime easternStandardTime = new DateTime(DateTimeZone.forID("EST"));

    return easternStandardTime.getDayOfMonth() == 1 && easternStandardTime.getMonthOfYear() == 4
            && easternStandardTime.getYear() == year;
}

From source file:com.uber.hoodie.cli.utils.HiveUtil.java

License:Apache License

public static long countRecords(String jdbcUrl, HoodieTableMetaClient source, String srcDb, int partitions,
        String user, String pass) throws SQLException {
    DateTime dateTime = DateTime.now();
    String endDateStr = dateTime.getYear() + "-" + String.format("%02d", dateTime.getMonthOfYear()) + "-"
            + String.format("%02d", dateTime.getDayOfMonth());
    dateTime = dateTime.minusDays(partitions);
    String startDateStr = dateTime.getYear() + "-" + String.format("%02d", dateTime.getMonthOfYear()) + "-"
            + String.format("%02d", dateTime.getDayOfMonth());
    System.out.println("Start date " + startDateStr + " and end date " + endDateStr);
    return countRecords(jdbcUrl, source, srcDb, startDateStr, endDateStr, user, pass);
}