List of usage examples for org.joda.time LocalDate getDayOfMonth
public int getDayOfMonth()
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate, final int nHours, final int nMinutes, final int nSeconds, final int nMilliSeconds) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth(), nHours, nMinutes, nSeconds, nMilliSeconds);// w ww . ja v a 2 s.com }
From source file:com.helger.datetime.xml.PDTXMLConverter.java
License:Apache License
/** * Get the passed object as {@link XMLGregorianCalendar} date (without a * time).// w w w . j av a 2 s . c o m * * @param aBase * The source object. May be <code>null</code>. * @return <code>null</code> if the parameter is <code>null</code>. */ @Nullable public static XMLGregorianCalendar getXMLCalendarDate(@Nullable final LocalDate aBase) { return aBase == null ? null : s_aDTFactory.newXMLGregorianCalendarDate(aBase.getYear(), aBase.getMonthOfYear(), aBase.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED); }
From source file:com.jseppa.mql4java.util.DateUtil.java
License:Apache License
public static DateTime addDateAndTime(LocalDate date, LocalTime time) { return new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), DATE_TZ); }
From source file:com.mbc.jfin.daycount.impl.calculator.AFBActualActualDaycountCalculator.java
License:Open Source License
public double calculateDaycountFraction(SchedulePeriod period) { int daysBetween = DateUtils.daysBetween(period.getStart(), period.getEnd()); if (daysBetween == 0) return 0; LocalDate newD2 = period.getEnd(); LocalDate temp = period.getEnd(); double sum = 0.0; while (temp.isAfter(period.getStart())) { temp = newD2;//from w ww . ja va2 s .c om temp = temp.minus(Years.ONE); if (temp.getDayOfMonth() == 28 && temp.getMonthOfYear() == 2 && DateUtils.isLeapYear(temp)) { temp = temp.plus(Days.ONE); } if (temp.isAfter(period.getStart()) || temp.equals(period.getStart())) { sum += 1.0; newD2 = temp; } } double den = 365.0; if (DateUtils.isLeapYear(newD2)) { temp = newD2; temp = new LocalDate(temp.getYear(), 2, 29); if (newD2.isAfter(temp) && (period.getStart().isBefore(temp) || period.getStart().equals(temp))) den += 1.0; } else if (DateUtils.isLeapYear(period.getStart())) { temp = new LocalDate(period.getStart().getYear(), 2, 29); if (newD2.isAfter(temp) && (period.getStart().isBefore(temp) || period.getStart().equals(temp))) den += 1.0; } return sum + DateUtils.daysBetween(period.getStart(), newD2) / den; }
From source file:com.mbc.jfin.util.DateUtils.java
License:Open Source License
public static boolean isLastDayOfMonth(LocalDate date) { return date.getDayOfMonth() == getDaysInMonth(date); }
From source file:com.metinkale.prayerapp.HicriDate.java
License:Apache License
public HicriDate(LocalDate greg) { // int[] key = {d, m, y}; //int[] ret = mCache.get(key); //if (ret != null) return ret; int hfix = Prefs.getHijriFix(); if (hfix != 0) { greg = greg.plusDays(hfix);/*from ww w. j a v a 2s . c o m*/ } int d = greg.getDayOfMonth(); int m = greg.getMonthOfYear(); int y = greg.getYear(); int[] last = null; for (int[] date : mDates) { if (date[GY] < y) { last = date; } else if ((date[GY] == y) && (date[GM] < m)) { last = date; } else if ((date[GY] == y) && (date[GM] == m) && (date[GD] <= d)) { last = date; } else { break; } } if (last == null) { LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance()) .toLocalDate(); Year = date.getYear(); Month = date.getMonthOfYear(); Day = date.getDayOfMonth(); } else { int[] h = { last[HD], last[HM], last[HY] }; h[0] += new LocalDate(y, m, d).getDayOfYear() - new LocalDate(last[GY], last[GM], last[GD]).getDayOfYear(); if ((h[0] >= 30) || (h[0] <= 0)) { LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance()) .toLocalDate(); Year = date.getYear(); Month = date.getMonthOfYear(); Day = date.getDayOfMonth(); } else { Year = h[HY]; Month = h[HM]; Day = h[HD]; } } }
From source file:com.metinkale.prayerapp.HicriDate.java
License:Apache License
public static int isHolyday() { LocalDate day = LocalDate.now(); for (int[] date : mDates) { if (date[GD] == day.getDayOfMonth() && (date[GM] == day.getMonthOfYear()) && (date[GY] == day.getYear())) { return date[DAY]; }/* w ww .j a va 2s . c o m*/ } return 0; }
From source file:com.metinkale.prayerapp.Utils.java
License:Apache License
@Nullable public static String format(@NonNull LocalDate date) { String format = getDateFormat(false); format = format.replace("DD", az(date.getDayOfMonth(), 2)); try {/* w w w. j a va 2s . c om*/ format = format.replace("MMM", getGregMonth(date.getMonthOfYear() - 1)); } catch (ArrayIndexOutOfBoundsException ex) { Crashlytics.logException(ex); return ""; } format = format.replace("MM", az(date.getMonthOfYear(), 2)); format = format.replace("YYYY", az(date.getYear(), 4)); format = format.replace("YY", az(date.getYear(), 2)); return toArabicNrs(format); }
From source file:com.metinkale.prayerapp.vakit.fragments.MainFragment.java
License:Apache License
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.notification: Fragment frag = getActivity().getSupportFragmentManager().findFragmentByTag("notPrefs"); if (frag == null) { ((Main) getActivity()).setFooterText("", false); getActivity().getSupportFragmentManager().beginTransaction() .add(R.id.fragContainer, NotificationPrefs.create(mTimes), "notPrefs") .commitAllowingStateLoss(); } else {//from www.j a v a2s .co m ((Main) getActivity()).setFooterText(getString(R.string.monthly), true); getActivity().getSupportFragmentManager().beginTransaction().remove(frag).commitAllowingStateLoss(); } AppRatingDialog.addToOpenedMenus("notPrefs"); break; case R.id.export: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.export).setItems(new CharSequence[] { "CSV", "PDF" }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, final int which) { long minDate = 0; long maxDate = Long.MAX_VALUE; if (mTimes instanceof WebTimes) { minDate = ((WebTimes) mTimes).getFirstSyncedDay().toDateTimeAtCurrentTime() .getMillis(); maxDate = ((WebTimes) mTimes).getLastSyncedDay().toDateTimeAtCurrentTime() .getMillis(); } final LocalDate ld = LocalDate.now(); final long finalMaxDate = maxDate; DatePickerDialog dlg = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker datePicker, int y, int m, int d) { final LocalDate from = new LocalDate(y, m + 1, d); DatePickerDialog dlg1 = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker datePicker, int y1, int m1, int d1) { final LocalDate to = new LocalDate(y1, m1 + 1, d1); try { export(which, from, to); } catch (IOException e) { e.printStackTrace(); Crashlytics.logException(e); Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show(); } } }, ld.getYear(), ld.getMonthOfYear() - 1, ld.getDayOfMonth()); DateTime startDate = DateTime.now().withDate(y, m + 1, d); long start = startDate.getMillis(); if (which == 1) dlg1.getDatePicker().setMaxDate( Math.min(finalMaxDate, startDate.plusDays(31).getMillis())); else dlg1.getDatePicker().setMaxDate(finalMaxDate); dlg1.getDatePicker().setMinDate( Math.min(start, dlg1.getDatePicker().getMaxDate()) - 1); dlg1.setTitle(R.string.to); dlg1.show(); } }, ld.getYear(), ld.getMonthOfYear() - 1, ld.getDayOfMonth()); dlg.getDatePicker().setMinDate(minDate); dlg.getDatePicker().setMaxDate(maxDate); dlg.setTitle(R.string.from); dlg.show(); } }); builder.show(); break; case R.id.refresh: if (mTimes instanceof WebTimes) { ((WebTimes) mTimes).syncAsync(); } break; case R.id.share: String txt = getString(R.string.shareTimes, mTimes.getName()) + ":"; LocalDate date = LocalDate.now(); String[] times = { mTimes.getTime(date, 0), mTimes.getTime(date, 1), mTimes.getTime(date, 2), mTimes.getTime(date, 3), mTimes.getTime(date, 4), mTimes.getTime(date, 5) }; for (int i = 0; i < times.length; i++) { txt += "\n " + Vakit.getByIndex(i).getString() + ": " + times[i]; } Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); sharingIntent.putExtra(Intent.EXTRA_TEXT, txt); startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share))); } return super.onOptionsItemSelected(item); }
From source file:com.metinkale.prayerapp.vakit.times.CalcTimes.java
License:Apache License
@Override public String _getTime(@NonNull LocalDate date, int time) { List<String> times = getPrayTime().getDatePrayerTimes(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), getLat(), getLng()); times.remove(4);//from ww w. ja va 2s.c o m return times.get(time); }