Java Code Examples for org.joda.time.LocalDateTime#getDayOfMonth()

The following examples show how to use org.joda.time.LocalDateTime#getDayOfMonth() . 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: StringColumnLocalDateTimeMapper.java    From jadira with Apache License 2.0 6 votes vote down vote up
@Override
public String toNonNullValue(LocalDateTime value) {

	String date = DATE_TIME_PRINTER_PREFIX.print(value);
	
	int dayOfMonth = value.getDayOfMonth();
	
    if (dayOfMonth < 10) {
    	date = date + "0";
    }
    date = date + dayOfMonth;
	
	String millis = LOCAL_MILLIS_PRINTER.print(value);
	while (millis.length() > 1 && millis.endsWith("0")) {
		millis = millis.substring(0, millis.length() - 1);
	}
	
    String formatted = date + "T" + LOCAL_TIME_PRINTER.print(value) + "." + millis;
    return formatted;
}
 
Example 2
Source File: DateTimeUtil.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
public static long toATechDate(LocalDateTime ldt) {
    long atechDateTime = 0L;

    atechDateTime += ldt.getYear() * 10000000000L;
    atechDateTime += ldt.getMonthOfYear() * 100000000L;
    atechDateTime += ldt.getDayOfMonth() * 1000000L;
    atechDateTime += ldt.getHourOfDay() * 10000L;
    atechDateTime += ldt.getMinuteOfHour() * 100L;
    atechDateTime += ldt.getSecondOfMinute();

    return atechDateTime;
}
 
Example 3
Source File: SegmentGenerationWithTimeColumnTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAllowedValue() {
  long millis = validMinTime; // is in UTC from epoch (19710101)
  DateTime dateTime = new DateTime(millis, DateTimeZone.UTC);
  LocalDateTime localDateTime = dateTime.toLocalDateTime();
  int year = localDateTime.getYear();
  int month = localDateTime.getMonthOfYear();
  int day = localDateTime.getDayOfMonth();
  Assert.assertEquals(year, 1971);
  Assert.assertEquals(month, 1);
  Assert.assertEquals(day, 1);
}
 
Example 4
Source File: SegmentGenerationWithTimeColumnTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
private Object getRandomValueForTimeColumn(boolean isSimpleDate, boolean isInvalidDate) {
  long randomMs = validMinTime + (long) (_random.nextDouble() * (startTime - validMinTime));
  Preconditions.checkArgument(TimeUtils.timeValueInValidRange(randomMs), "Value " + randomMs + " out of range");
  long dateColVal = randomMs;
  Object result;
  if (isInvalidDate) {
    result = new Long(new DateTime(2072, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC).getMillis());
    return result;
  } else if (isSimpleDate) {
    DateTime dateTime = new DateTime(randomMs, DateTimeZone.UTC);
    LocalDateTime localDateTime = dateTime.toLocalDateTime();
    int year = localDateTime.getYear();
    int month = localDateTime.getMonthOfYear();
    int day = localDateTime.getDayOfMonth();
    String dateColStr = String.format("%04d%02d%02d", year, month, day);
    dateColVal = Integer.valueOf(dateColStr);
    result = new Integer(Integer.valueOf(dateColStr));
  } else {
    result = new Long(dateColVal);
  }

  if (dateColVal < minTime) {
    minTime = dateColVal;
  }
  if (dateColVal > maxTime) {
    maxTime = dateColVal;
  }
  return result;
}
 
Example 5
Source File: ScheduleOffsetResolver.java    From qmq with Apache License 2.0 4 votes vote down vote up
private static long day(final LocalDateTime localDateTime) {
    return localDateTime.getDayOfMonth() * 10000L;
}
 
Example 6
Source File: WeekFragment.java    From RWeekCalendar with MIT License 4 votes vote down vote up
/**
 * Setting date when selected form picker
 *
 * @param mSelectedDate
 */

public void ChangeSelector(LocalDateTime mSelectedDate) {

    LocalDateTime startDate=AppController.getInstance().getDate();
    int addDays=datePosition*7;


    startDate = startDate.plusDays(addDays);

    for (int i = 0; i < 7; i++) {

        if (mSelectedDate.getDayOfMonth() == startDate.getDayOfMonth()) {
            textViewArray[i].setBackgroundResource(selectorDateIndicatorValue);
            mDateSelectedBackground(i);


        }
        startDate=startDate.plusDays(1);

    }
}
 
Example 7
Source File: DateTimeUtil.java    From AndroidAPS with GNU Affero General Public License v3.0 3 votes vote down vote up
public static boolean isSameDay(LocalDateTime ldt1, LocalDateTime ldt2) {

        return (ldt1.getYear() == ldt2.getYear() && //
                ldt1.getMonthOfYear() == ldt2.getMonthOfYear() && //
                ldt1.getDayOfMonth() == ldt2.getDayOfMonth());

    }