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

The following examples show how to use org.joda.time.DateTime#minusMillis() . 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: EventsExportEventsToICal.java    From unitime with Apache License 2.0 6 votes vote down vote up
public ICalendarMeeting(MeetingInterface meeting, Status status) {
	if (meeting.getStartTime() != null) {
		iStart = new DateTime(meeting.getStartTime());
	} else {
		iStart = new DateTime(meeting.getMeetingDate()).plusMinutes((5 * meeting.getStartSlot()) + meeting.getStartOffset());
	}
	if (meeting.getStartTime() != null) {
		iEnd = new DateTime(meeting.getStopTime());
	} else {
		iEnd = new DateTime(meeting.getMeetingDate()).plusMinutes((5 * meeting.getEndSlot()) + meeting.getEndOffset());
	}
	if (iStart.getSecondOfMinute() != 0) iStart = iStart.minusSeconds(iStart.getSecondOfMinute());
	if (iEnd.getSecondOfMinute() != 0) iEnd = iEnd.minusSeconds(iEnd.getSecondOfMinute());
	if (iStart.getMillisOfSecond() != 0) iStart = iStart.minusMillis(iStart.getMillisOfSecond());
	if (iEnd.getMillisOfSecond() != 0) iEnd = iEnd.minusMillis(iEnd.getMillisOfSecond());
	iLocation = meeting.getLocationName(MESSAGES);
	iStatus = (status != null ? status : meeting.isApproved() ? Status.confirmed() : Status.tentative());
}
 
Example 2
Source File: CalendarFragment.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
private void updateIndicatorSet() {

        mIndicatorsYear = mCalendar.get(Calendar.YEAR);

        MutableArrayList<Entry> toFilter = new MutableArrayList<>();
        toFilter.addAll(mainActivity.entries);

        DateTime yearStart = DateTime.now();
        yearStart = yearStart.withDate(mCalendar.get(Calendar.YEAR), 1, 1);
        yearStart = yearStart.withTimeAtStartOfDay();

        DateTime yearEnd = yearStart.plusYears(1).withTimeAtStartOfDay();
        yearEnd = yearEnd.minusMillis(1);

        Log.d("", "Start Year: " + yearStart.toString());
        Log.d("", "End Year: " + yearEnd.toString());

        EntryDateRangePredicate pred = new EntryDateRangePredicate(yearStart.getMillis(), yearEnd.getMillis());
        toFilter.filter(pred);

        HashSet<Integer> mDays = new HashSet<>();
        for (int i = 0; i < toFilter.size(); i++) {
            Entry e = toFilter.get(i);
            int year = e.creationDate.get(Calendar.YEAR);
            int month = e.creationDate.get(Calendar.MONTH);
            int day = e.creationDate.get(Calendar.DAY_OF_MONTH);
            int key = year + (month * 10000) + (day * 1000000);

            if (!mDays.contains(key))
                mDays.add(key);
        }

        mDayPickerView.setIndicators(mDays);
        toFilter.clear();
    }
 
Example 3
Source File: MessageRateStats.java    From ade with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Return the end of day of yesterday
 * @param dateTime
 * @return
 */
private DateTime getYesterdayEndOfDay(DateTime dateTime) {
    dateTime = dateTime.withTimeAtStartOfDay();
    dateTime = dateTime.minusMillis(1);

    return dateTime;
}
 
Example 4
Source File: AugmentBaseDataVisitor.java    From spork with Apache License 2.0 4 votes vote down vote up
Object GetSmallerValue(Object v) {
    byte type = DataType.findType(v);

    if (type == DataType.BAG || type == DataType.TUPLE
            || type == DataType.MAP)
        return null;

    switch (type) {
    case DataType.CHARARRAY:
        String str = (String) v;
        if (str.length() > 0)
            return str.substring(0, str.length() - 1);
        else
            return null;
    case DataType.BYTEARRAY:
        DataByteArray data = (DataByteArray) v;
        if (data.size() > 0)
            return new DataByteArray(data.get(), 0, data.size() - 1);
        else
            return null;
    case DataType.INTEGER:
        return Integer.valueOf((Integer) v - 1);
    case DataType.LONG:
        return Long.valueOf((Long) v - 1);
    case DataType.FLOAT:
        return Float.valueOf((Float) v - 1);
    case DataType.DOUBLE:
        return Double.valueOf((Double) v - 1);
    case DataType.BIGINTEGER:
        return ((BigInteger)v).subtract(BigInteger.ONE);
    case DataType.BIGDECIMAL:
        return ((BigDecimal)v).subtract(BigDecimal.ONE);
    case DataType.DATETIME:
        DateTime dt = (DateTime) v;
        if (dt.getMillisOfSecond() != 0) {
            return dt.minusMillis(1);
        } else if (dt.getSecondOfMinute() != 0) {
            return dt.minusSeconds(1);
        } else if (dt.getMinuteOfHour() != 0) {
            return dt.minusMinutes(1);
        } else if (dt.getHourOfDay() != 0) {
            return dt.minusHours(1);
        } else {
            return dt.minusDays(1);
        }
    default:
        return null;
    }

}
 
Example 5
Source File: DateMinusMilliseconds.java    From levelup-java-examples with Apache License 2.0 3 votes vote down vote up
@Test
public void subtract_milliseconds_from_date_in_java_with_joda () {
	
	DateTime newYearsDay = new DateTime(2013, 1, 1, 0, 0, 0, 0);
	DateTime newYearsEve = newYearsDay.minusMillis(60);

	DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss S z");
	
	logger.info(newYearsDay.toString(fmt));
	logger.info(newYearsEve.toString(fmt));

	assertTrue(newYearsEve.isBefore(newYearsDay));
}