下面列出了org.joda.time.LocalDate#toDateTimeAtStartOfDay ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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");
}
}
@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);
}
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();
}
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;
}
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;
}
public DateTime getPaymentLimitDateTime() {
ResidenceYear residenceYear = getYear();
LocalDate date =
new LocalDate(residenceYear.getYear(), getMonth().getNumberOfMonth(), getManagementUnit()
.getCurrentPaymentLimitDay());
return date.toDateTimeAtStartOfDay();
}
@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);
}
}
@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);
}
}
private static DateTime getEndDayOfFirstBiWeek(DateTime date){
DateTime startDay = getStartDayOfFirstBiWeek(date);
LocalDate localDate = new LocalDate(startDay);
localDate = localDate.plusDays( 13 );
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime getStartDayOfSecondBiWeek(DateTime date){
LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
localDate = localDate.plusDays(14);
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime getEndDayOfSecondBiWeek(DateTime date){
DateTime startDay = getStartDayOfSecondBiWeek(date);
LocalDate localDate = new LocalDate(startDay);
localDate = localDate.plusDays( 13 );
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime getStartDayOfNextMonthBiWeek(DateTime date){
LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
localDate = localDate.plusDays(28);
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime getEndDayOfNextMonthBiWeek(DateTime date){
DateTime startDay = getStartDayOfNextMonthBiWeek(date);
LocalDate localDate = new LocalDate(startDay);
localDate = localDate.plusDays( 13 );
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime getStartDayOfPreviousMonthBiWeek(DateTime date){
LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
localDate = localDate.minusDays(14);
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime getEndDayOfPreviousMonthBiWeek(DateTime date){
DateTime startDay = getStartDayOfFirstBiWeek(date);
LocalDate localDate = new LocalDate(startDay);
localDate = localDate.minusDays( 14 );
return localDate.toDateTimeAtStartOfDay();
}
public Fine(LocalDate date, BigDecimal amount, DebtEntry debtEntry, CreditEntry origin) {
super("", date.toDateTimeAtStartOfDay(), date, "", amount);
this.target = debtEntry;
this.date = date;
this.origin = origin;
}
public DateTime getPaymentStartDate() {
LocalDate date = new LocalDate(getYear().getYear(), getMonth().getNumberOfMonth(), 1);
return date.toDateTimeAtStartOfDay();
}
private static DateTime toDateTime(final LocalDate localDate) {
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime toDateTime(final LocalDate localDate) {
return localDate.toDateTimeAtStartOfDay();
}
private static DateTime toDateTime(final LocalDate localDate) {
return localDate.toDateTimeAtStartOfDay();
}