Example usage for org.joda.time DateTime getDayOfMonth

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

Introduction

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

Prototype

public int getDayOfMonth() 

Source Link

Document

Get the day of month field value.

Usage

From source file:com.marand.thinkmed.medications.dto.report.TherapyDayReportUtils.java

License:Open Source License

private static String combineTimeAndQuantity(final DateTime date, final String time, final String quantity) {
    final StringBuilder sb = new StringBuilder();

    if (date != null) {
        sb.append("<br>" + date.getDayOfMonth() + "." + date.getMonthOfYear());
    }/*w  w w .j a va2 s.com*/

    sb.append("<br>&nbsp;&nbsp;&nbsp;&nbsp;" + time + "&nbsp;-&nbsp;" + quantity);

    return sb.toString();
}

From source file:com.marand.thinkmed.medications.process.impl.TherapyTaskCreatorImpl.java

License:Open Source License

private List<NewTaskRequestDto> createTasks(final Long patientId, final MedicationOrderComposition composition,
        final MedicationInstructionInstruction instruction, final AdministrationTimingDto administrationTiming,
        final RoundsIntervalDto roundsInterval, final List<Interval> tasksCreationIntervals,
        final boolean therapyStart, final DateTime lastTaskTimestamp) {
    final boolean simple = MedicationsEhrUtils.isSimpleInstruction(instruction);
    final boolean variable = MedicationsEhrUtils.isVariableInstruction(instruction);
    final boolean variableDays = MedicationsEhrUtils.isVariableDaysInstruction(instruction);
    String linkedTherapyId = null; //last task triggers task creation for linked therapy

    final Pair<MedicationOrderComposition, MedicationInstructionInstruction> instructionPair = Pair
            .of(composition, instruction);
    for (final MedicationInstructionInstruction inst : composition.getMedicationDetail()
            .getMedicationInstruction()) {
        if (medicationsBo.doesInstructionHaveLinkToCompareInstruction(inst, instructionPair,
                OpenEhrLinkType.ISSUE)) {
            linkedTherapyId = InstructionTranslator.translate(inst, composition);
            break;
        }//from   ww  w. j ava 2 s.co  m
    }

    final List<NewTaskRequestDto> taskRequests = new ArrayList<>();
    for (final Interval interval : tasksCreationIntervals) {
        if (variableDays) {
            final Map<DateTime, TherapyDoseDto> administrationDateTimesMap = new HashMap<>();
            for (final OrderActivity orderActivity : instruction.getOrder()) {
                final TherapyDoseDto dose = getTherapyDoseDto(orderActivity, simple);
                if (dose != null) {
                    final DvTime dvTime = orderActivity.getMedicationTiming().getTiming().getTime().get(0);
                    final DvDate dvDate = orderActivity.getMedicationTiming().getTiming().getDate().get(0);
                    final Pair<Integer, Integer> parsedTime = DvUtils.getHourMinute(dvTime);
                    final DateTime parsedDate = ISODateTimeFormat.date().parseDateTime(dvDate.getValue());

                    administrationDateTimesMap.put(
                            new DateTime(parsedDate.getYear(), parsedDate.getMonthOfYear(),
                                    parsedDate.getDayOfMonth(), parsedTime.getFirst(), parsedTime.getSecond()),
                            dose);
                }
            }
            final List<NewTaskRequestDto> tasks = createTasksForVariableDaysTherapy(patientId, instruction,
                    composition.getUid().getValue(), interval, administrationDateTimesMap, therapyStart);
            taskRequests.addAll(tasks);
        } else if (variable) {
            final Map<HourMinuteDto, TherapyDoseDto> administrationTimesMap = new HashMap<>();
            for (final OrderActivity orderActivity : instruction.getOrder()) {
                final TherapyDoseDto dose = getTherapyDoseDto(orderActivity, simple);
                final Pair<Integer, Integer> parsedTime = DvUtils
                        .getHourMinute(orderActivity.getMedicationTiming().getTiming().getTime().get(0));
                administrationTimesMap.put(new HourMinuteDto(parsedTime.getFirst(), parsedTime.getSecond()),
                        dose);
            }
            final List<NewTaskRequestDto> tasks = createTasksForVariableTherapy(patientId, instruction,
                    composition.getUid().getValue(), interval, administrationTimesMap, therapyStart);
            taskRequests.addAll(tasks);
        } else {
            final TherapyDoseDto dose = getTherapyDoseDto(instruction.getOrder().get(0), simple);
            final List<NewTaskRequestDto> tasks = createTasksForConstantTherapy(patientId, instruction,
                    composition.getUid().getValue(), interval, dose, administrationTiming, roundsInterval,
                    therapyStart, lastTaskTimestamp, linkedTherapyId);
            taskRequests.addAll(tasks);
        }
    }
    return taskRequests;
}

From source file:com.marand.thinkmed.medications.process.impl.TherapyTaskCreatorImpl.java

License:Open Source License

private DateTime combine(final DateTime fromTime, final HourMinuteDto hourMinuteDto) {
    return new DateTime(fromTime.getYear(), fromTime.getMonthOfYear(), fromTime.getDayOfMonth(),
            hourMinuteDto.getHour(), hourMinuteDto.getMinute());
}

From source file:com.marklogic.samplestack.dbclient.DateFacetBuilder.java

License:Apache License

public static ObjectNode dateFacet(DateTime min, DateTime max) {
    DateFacetBuilder fb = new DateFacetBuilder(new CustomObjectMapper());
    fb.name("date");
    /*//from w  w w.  j  a v a2 s  . c  o  m
    long interval = max.getMillis() - min.getMillis();
    if (interval / BucketInterval.BY_DAY.bucketDuration() < 40) {
       fb.period("DAY");
       DateTime bucketStart = min.minus(min.getMillisOfDay());
       while (bucketStart.isBefore(max)) {
    DateTime bucketEnd = bucketStart.plusDays(1);
    fb.bucket(bucketStart, bucketEnd);
    bucketStart = bucketStart.plusDays(1);
       }
    }
    else if (interval / BucketInterval.BY_WEEK.bucketDuration() < 40) {
       fb.period("WEEK");
       DateTime bucketStart = min.minusDays(min.getDayOfWeek()).minus(min.getMillisOfDay());
       while (bucketStart.isBefore(max)) {
    DateTime bucketEnd = bucketStart.plusWeeks(1);
    fb.bucket(bucketStart, bucketEnd);
    bucketStart = bucketStart.plusWeeks(1);
       }
    } else {
    */
    // for 8.0-1 we are only doing facets by month
    fb.period("MONTH");
    DateTime bucketStart = min.minusDays(min.getDayOfMonth() - 1).minus(min.getMillisOfDay());
    bucketStart = new DateTime(bucketStart);
    while (bucketStart.isBefore(max)) {
        DateTime bucketEnd = bucketStart.plusMonths(1);
        fb.bucket(bucketStart, bucketEnd);
        bucketStart = bucketStart.plusMonths(1);
    }
    // }
    return fb.facetNode;
}

From source file:com.microsoft.exchange.utils.TimeZoneHelper.java

License:Open Source License

private static SerializableTimeZoneTime toSerializableTimeZoneTime(DateTimeZone zone, long transition) {
    int standardOffset = zone.getStandardOffset(transition);
    long offset = zone.getOffset(transition);
    int bias = toBias(offset - standardOffset);
    DateTime time = new DateTime(transition, zone);
    short month = (short) time.getMonthOfYear();
    short day = (short) time.getDayOfMonth();
    DayOfWeekType dayOfWeek = toDayOfWeek(time.getDayOfWeek());
    return new SerializableTimeZoneTime(bias, time.toString("HH:mm:ss"), day, month, dayOfWeek,
            time.toString("yyyy"));
}

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionEditActivity.java

License:Open Source License

private void initializePaymentDateSelector() {
    if (mViewHolder.paymentDateTextView == null)
        return;//from ww w  .  jav  a 2  s.  c o m

    DateTime paymentDate = getRecurringTransaction().getPaymentDate();
    mViewHolder.paymentDateTextView.setText(paymentDate.toString(Constants.LONG_DATE_PATTERN));
    //        mViewHolder.paymentDateTextView.setTag(paymentDate.toString(Constants.ISO_DATE_FORMAT));

    mViewHolder.paymentDateTextView.setOnClickListener(new View.OnClickListener() {
        CalendarDatePickerDialogFragment.OnDateSetListener listener = new CalendarDatePickerDialogFragment.OnDateSetListener() {
            @Override
            public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear,
                    int dayOfMonth) {
                DateTime dateTime = MmxDateTimeUtils.from(year, monthOfYear + 1, dayOfMonth);

                setPaymentDate(dateTime);
            }
        };

        @Override
        public void onClick(View v) {
            // Show calendar with the current date selected.

            DateTime dateTime = getPaymentDate();

            CalendarDatePickerDialogFragment datePicker = new CalendarDatePickerDialogFragment()
                    .setFirstDayOfWeek(MmxDateTimeUtils.getFirstDayOfWeek()).setOnDateSetListener(listener)
                    .setPreselectedDate(dateTime.getYear(), dateTime.getMonthOfYear() - 1,
                            dateTime.getDayOfMonth());
            if (new UIHelper(RecurringTransactionEditActivity.this).isDarkTheme()) {
                datePicker.setThemeDark();
            }
            datePicker.show(getSupportFragmentManager(), TAG_DATEPICKER);
        }
    });

    mViewHolder.paymentPreviousDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = getPaymentDate().minusDays(1);
            setPaymentDate(dateTime);
        }
    });

    mViewHolder.paymentNextDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = getPaymentDate().plusDays(1);
            setPaymentDate(dateTime);
        }
    });
}

From source file:com.money.manager.ex.search.OnDateButtonClickListener.java

License:Open Source License

@Override
public void onClick(View v) {
    DateTime dateTime = MmxDateTimeUtils.today();
    String calendarValue = mTextView.getText().toString();

    if (!TextUtils.isEmpty(calendarValue)) {
        String userDatePattern = new MmxDateTimeUtils(mParent.getApplicationContext()).getUserDatePattern();
        DateTimeFormatter formatter = DateTimeFormat.forPattern(userDatePattern);
        dateTime = formatter.parseDateTime(calendarValue);
    }/* w  w w  .ja va  2  s  .com*/

    CalendarDatePickerDialogFragment datePicker = new CalendarDatePickerDialogFragment()
            .setFirstDayOfWeek(MmxDateTimeUtils.getFirstDayOfWeek()).setOnDateSetListener(mDateSetListener)
            .setPreselectedDate(dateTime.getYear(), dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth());
    if (new UIHelper(mParent).isDarkTheme()) {
        datePicker.setThemeDark();
    }
    datePicker.show(mParent.getSupportFragmentManager(), DATEPICKER_TAG);
}

From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java

License:Open Source License

/**
 * Due Date picker/*from  ww w . j av a 2 s  .c o m*/
 */
public void initDateSelector() {
    DateTime date = this.transactionEntity.getDate();
    if (date == null) {
        date = DateTime.now();
        transactionEntity.setDate(date);
    }
    showDate(date);

    viewHolder.dateTextView.setOnClickListener(new View.OnClickListener() {
        CalendarDatePickerDialogFragment.OnDateSetListener listener = new CalendarDatePickerDialogFragment.OnDateSetListener() {
            @Override
            public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear,
                    int dayOfMonth) {
                DateTime dateTime = MmxDateTimeUtils.from(year, monthOfYear + 1, dayOfMonth);
                setDate(dateTime);
            }
        };

        @Override
        public void onClick(View v) {
            DateTime dateTime = transactionEntity.getDate();

            CalendarDatePickerDialogFragment datePicker = new CalendarDatePickerDialogFragment()
                    .setOnDateSetListener(listener).setFirstDayOfWeek(MmxDateTimeUtils.getFirstDayOfWeek())
                    .setPreselectedDate(dateTime.getYear(), dateTime.getMonthOfYear() - 1,
                            dateTime.getDayOfMonth());
            if (new UIHelper(getContext()).isDarkTheme()) {
                datePicker.setThemeDark();
            }
            datePicker.show(mParent.getSupportFragmentManager(), DATEPICKER_TAG);
        }
    });

    viewHolder.previousDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = transactionEntity.getDate().minusDays(1);
            setDate(dateTime);
        }
    });

    viewHolder.nextDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = transactionEntity.getDate().plusDays(1);
            setDate(dateTime);
        }
    });
}

From source file:com.money.manager.ex.utils.MmxDateTimeUtils.java

License:Open Source License

public static void setDatePicker(DateTime date, DatePicker datePicker) {
    datePicker.updateDate(date.getYear(), date.getMonthOfYear() - 1, date.getDayOfMonth());
}

From source file:com.mpower.daktar.android.widgets.DateTimeWidget.java

License:Apache License

private void setAnswer() {

    if (mPrompt.getAnswerValue() != null) {

        final DateTime ldt = new DateTime(
                ((Date) ((DateTimeData) mPrompt.getAnswerValue()).getValue()).getTime());
        mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
        mTimePicker.setCurrentHour(ldt.getHourOfDay());
        mTimePicker.setCurrentMinute(ldt.getMinuteOfHour());

    } else {//from   w w  w.  j a  v  a  2  s  .c  om
        // create time widget with current time as of right now
        clearAnswer();
    }
}