Java Code Examples for org.joda.time.LocalDate#toDateTimeAtStartOfDay()

The following examples show how to use org.joda.time.LocalDate#toDateTimeAtStartOfDay() . 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: DocumentRepository.java    From estatio with Apache License 2.0 6 votes vote down vote up
@Programmatic
public List<Document> findBetween(final LocalDate startDate, final LocalDate endDateIfAny) {

    final DateTime startDateTime = startDate.toDateTimeAtStartOfDay();

    final QueryDefault<Document> query;
    if (endDateIfAny != null) {
        final DateTime endDateTime = endDateIfAny.plusDays(1).toDateTimeAtStartOfDay();
        query = new QueryDefault<>(Document.class,
                "findByCreatedAtBetween",
                "startDateTime", startDateTime,
                "endDateTime", endDateTime);
    }
    else {
        query = new QueryDefault<>(Document.class,
                "findByCreatedAtAfter",
                "startDateTime", startDateTime);
    }

    return repositoryService.allMatches(query);
}
 
Example 2
Source File: PostingRulesManager.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Atomic
public static void createDEAStandaloneGratuityPostingRule(StandaloneInstallmentBean bean,
        DegreeCurricularPlan degreeCurricularPlan) {
    DegreeCurricularPlanServiceAgreementTemplate dcpSAT = degreeCurricularPlan.getServiceAgreementTemplate();
    if (dcpSAT != null) {
        YearMonthDay startDate = bean.getStartDate();

        LocalDate startLocalDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), startDate.getDayOfMonth());
        BigDecimal ectsForYear = bean.getEctsForYear();
        BigDecimal gratuityFactor = bean.getGratuityFactor();
        BigDecimal ectsFactor = bean.getEctsFactor();

        new StandaloneEnrolmentGratuityPR(startLocalDate.toDateTimeAtStartOfDay(), null, dcpSAT, ectsForYear, gratuityFactor,
                ectsFactor);
    } else {
        throw new DomainException("StandaloneEnrolmentGratuityPR.DegreeCurricularPlanServiceAgreementTemplate.cannot.be.null");
    }
}
 
Example 3
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static DateTime getStartDayOfFirstBiWeek(DateTime date){
    LocalDate localDate = new LocalDate( date.getYear(), date.getMonthOfYear(), 1 );
    while ( localDate.getDayOfWeek() != DateTimeConstants.MONDAY ) {
        localDate = localDate.plusDays( 1 );
    }
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 4
Source File: ResidenceMonth.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public DateTime getPaymentLimitDateTime() {
    ResidenceYear residenceYear = getYear();
    LocalDate date =
            new LocalDate(residenceYear.getYear(), getMonth().getNumberOfMonth(), getManagementUnit()
                    .getCurrentPaymentLimitDay());
    return date.toDateTimeAtStartOfDay();
}
 
Example 5
Source File: Interest.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Interest(LocalDate date, BigDecimal amount, DebtEntry debtEntry, CreditEntry origin, InterestRateBean
        interestRateBean) {
    super("", date.toDateTimeAtStartOfDay(), date, "", amount);
    this.origin = origin;
    this.target = debtEntry;
    this.interestRateBean = interestRateBean;
}
 
Example 6
Source File: AccountingReportService.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Spreadsheet reportList(LocalDate start, LocalDate end) {
      DateTime startDateTime = start.toDateTimeAtStartOfDay();
      DateTime endDateTime = end.toDateTimeAtStartOfDay();
  	Spreadsheet payments = new Spreadsheet("Pagamentos detalhados");
Bennu.getInstance().getAccountingTransactionDetailsSet().stream()
	.filter(atd -> !atd.getTransaction().isAdjustingTransaction())	
	.filter(atd -> isFor(atd, startDateTime, endDateTime))
      	.forEach(atd -> fillPayment(payments, atd));

return payments;
  }
 
Example 7
Source File: CommunicationChannel_findCommunications.java    From estatio with Apache License 2.0 4 votes vote down vote up
private static DateTime toDateTime(final LocalDate localDate) {
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 8
Source File: CalendarIntegrationService.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onHandleIntent(@NonNull Intent intent) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
        Preferences.CALENDAR_INTEGRATION.set("-1");
        return;
    }
    Context context = App.get();
    try {
        ContentResolver cr = context.getContentResolver();


        cr.delete(CalendarContract.Events.CONTENT_URI, CalendarContract.Events.DESCRIPTION + "=\"com.metinkale.prayer\"", null);

        Uri calenderUri = CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
                .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
                .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, ACCOUNT_TYPE).build();
        cr.delete(calenderUri,
                CalendarContract.Calendars.ACCOUNT_NAME + " = ? AND " + CalendarContract.Calendars.ACCOUNT_TYPE + " = ?",
                new String[]{ACCOUNT_NAME, ACCOUNT_TYPE});

        String id = Preferences.CALENDAR_INTEGRATION.get();

        if ("-1".equals(id)) {
            return;
        }

        List<ContentValues> events = new ArrayList<>();
        long calendarId = getCalendar(context);
        for (int year = HijriDate.getMinGregYear(); year <= HijriDate.getMaxGregYear(); year++) {


            for (Pair<HijriDate, Integer> date : HijriDate.getHolydaysForGregYear(year)) {
                if (date == null || date.second <= 0)
                    continue;
                ContentValues event = new ContentValues();

                event.put(CalendarContract.Events.CALENDAR_ID, calendarId);
                event.put(CalendarContract.Events.TITLE, LocaleUtils.getHolyday(date.second));
                event.put(CalendarContract.Events.DESCRIPTION, "com.metinkale.prayer");
                LocalDate ld = date.first.getLocalDate();
                DateTime cal = ld.toDateTimeAtStartOfDay(DateTimeZone.UTC);

                long dtstart = cal.getMillis();
                long dtend = cal.plusDays(1).getMillis();

                event.put(CalendarContract.Events.DTSTART, dtstart);
                event.put(CalendarContract.Events.DTEND, dtend);
                event.put(CalendarContract.Events.EVENT_TIMEZONE, Time.TIMEZONE_UTC);
                event.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CONFIRMED);
                event.put(CalendarContract.Events.ALL_DAY, 1);
                event.put(CalendarContract.Events.HAS_ALARM, 0);
                event.put(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_FREE);
                event.put(CalendarContract.Events.CUSTOM_APP_PACKAGE, getPackageName());
                event.put(CalendarContract.Events.CUSTOM_APP_URI, "https://prayerapp.page.link/calendar");


                events.add(event);
            }
        }
        cr.bulkInsert(CalendarContract.Events.CONTENT_URI, events.toArray(new ContentValues[0]));
    } catch (Exception e) {
        Preferences.CALENDAR_INTEGRATION.set("-1");
        Crashlytics.logException(e);
    }

}
 
Example 9
Source File: CommunicationChannelOwner_findCommunications.java    From estatio with Apache License 2.0 4 votes vote down vote up
private static DateTime toDateTime(final LocalDate localDate) {
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 10
Source File: CommunicationChannel_recentCommunications.java    From estatio with Apache License 2.0 4 votes vote down vote up
private static DateTime toDateTime(final LocalDate localDate) {
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 11
Source File: ResidenceMonth.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DateTime getPaymentStartDate() {
    LocalDate date = new LocalDate(getYear().getYear(), getMonth().getNumberOfMonth(), 1);
    return date.toDateTimeAtStartOfDay();
}
 
Example 12
Source File: Fine.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Fine(LocalDate date, BigDecimal amount, DebtEntry debtEntry, CreditEntry origin) {
    super("", date.toDateTimeAtStartOfDay(), date, "", amount);
    this.target = debtEntry;
    this.date = date;
    this.origin = origin;
}
 
Example 13
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getEndDayOfPreviousMonthBiWeek(DateTime date){
    DateTime startDay = getStartDayOfFirstBiWeek(date);
    LocalDate localDate = new LocalDate(startDay);
    localDate = localDate.minusDays( 14 );
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 14
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getStartDayOfPreviousMonthBiWeek(DateTime date){
    LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
    localDate = localDate.minusDays(14);
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 15
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getEndDayOfNextMonthBiWeek(DateTime date){
    DateTime startDay = getStartDayOfNextMonthBiWeek(date);
    LocalDate localDate = new LocalDate(startDay);
    localDate = localDate.plusDays( 13 );
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 16
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getStartDayOfNextMonthBiWeek(DateTime date){
    LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
    localDate = localDate.plusDays(28);
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 17
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getEndDayOfSecondBiWeek(DateTime date){
    DateTime startDay = getStartDayOfSecondBiWeek(date);
    LocalDate localDate = new LocalDate(startDay);
    localDate = localDate.plusDays( 13 );
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 18
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getStartDayOfSecondBiWeek(DateTime date){
    LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
    localDate = localDate.plusDays(14);
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 19
Source File: BiWeeklyPeriodFilter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static DateTime getEndDayOfFirstBiWeek(DateTime date){
    DateTime startDay = getStartDayOfFirstBiWeek(date);
    LocalDate localDate = new LocalDate(startDay);
    localDate = localDate.plusDays( 13 );
    return localDate.toDateTimeAtStartOfDay();
}
 
Example 20
Source File: CalendarIntegrationService.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onHandleIntent(@NonNull Intent intent) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
        Preferences.CALENDAR_INTEGRATION.set("-1");
        return;
    }
    Context context = App.get();
    try {
        ContentResolver cr = context.getContentResolver();


        cr.delete(CalendarContract.Events.CONTENT_URI, CalendarContract.Events.DESCRIPTION + "=\"com.metinkale.prayer\"", null);

        Uri calenderUri = CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
                .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
                .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, ACCOUNT_TYPE).build();
        cr.delete(calenderUri,
                CalendarContract.Calendars.ACCOUNT_NAME + " = ? AND " + CalendarContract.Calendars.ACCOUNT_TYPE + " = ?",
                new String[]{ACCOUNT_NAME, ACCOUNT_TYPE});

        String id = Preferences.CALENDAR_INTEGRATION.get();

        if ("-1".equals(id)) {
            return;
        }

        List<ContentValues> events = new ArrayList<>();
        long calendarId = getCalendar(context);
        for (int year = HijriDate.getMinGregYear(); year <= HijriDate.getMaxGregYear(); year++) {


            for (Pair<HijriDate, Integer> date : HijriDate.getHolydaysForGregYear(year)) {
                if (date == null || date.second <= 0)
                    continue;
                ContentValues event = new ContentValues();

                event.put(CalendarContract.Events.CALENDAR_ID, calendarId);
                event.put(CalendarContract.Events.TITLE, LocaleUtils.getHolyday(date.second));
                event.put(CalendarContract.Events.DESCRIPTION, "com.metinkale.prayer");
                LocalDate ld = date.first.getLocalDate();
                DateTime cal = ld.toDateTimeAtStartOfDay(DateTimeZone.UTC);

                long dtstart = cal.getMillis();
                long dtend = cal.plusDays(1).getMillis();

                event.put(CalendarContract.Events.DTSTART, dtstart);
                event.put(CalendarContract.Events.DTEND, dtend);
                event.put(CalendarContract.Events.EVENT_TIMEZONE, Time.TIMEZONE_UTC);
                event.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CONFIRMED);
                event.put(CalendarContract.Events.ALL_DAY, 1);
                event.put(CalendarContract.Events.HAS_ALARM, 0);
                event.put(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_FREE);
                event.put(CalendarContract.Events.CUSTOM_APP_PACKAGE, getPackageName());
                event.put(CalendarContract.Events.CUSTOM_APP_URI, "https://prayerapp.page.link/calendar");


                events.add(event);
            }
        }
        cr.bulkInsert(CalendarContract.Events.CONTENT_URI, events.toArray(new ContentValues[0]));
    } catch (Exception e) {
        Preferences.CALENDAR_INTEGRATION.set("-1");
        Crashlytics.logException(e);
    }

}