List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:com.hengyi.japp.execution.domain.Task.java
public boolean isOverTime() { return LocalDate.now().isAfter(LocalDate.fromDateFields(getEndDate())); }
From source file:com.javathlon.BuySubscriptionActivity.java
License:Open Source License
private void createPurchase(Double price, Long subscriptionId) { ApiClient apiClient = ApiClient.getApiClient(getApplicationContext()); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String subscriberID = preferences.getString(QuickstartPreferences.SUBSCRIBER_ID, ""); savePurchasedItem(selectedSubscription); PurchaseDTO purchaseDTO = new PurchaseDTO(); purchaseDTO.setPurchaseDate(LocalDate.now()); purchaseDTO.setChannel("android-app"); purchaseDTO.setPrice(price);/*ww w .ja va 2 s. c o m*/ purchaseDTO.setItemId(subscriptionId); purchaseDTO.setApplicationId(apiClient.appId); purchaseDTO.setSubscriberId(Long.valueOf(subscriberID)); purchaseDTO.setPaymentType("google wallet"); savePurchaseToserver(purchaseDTO); }
From source file:com.metinkale.prayerapp.calendar.Main.java
License:Apache License
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendar_main); SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setCurrentItem(LocalDate.now().getYear() - HicriDate.MIN_YEAR); }
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 w w . jav a 2s . c o m } return 0; }
From source file:com.metinkale.prayerapp.MainIntentService.java
License:Apache License
private void handleCalendarIntegration() { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) { Prefs.setCalendar("-1"); return;/*from www . j ava2s. co m*/ } Context context = App.get(); try { ContentResolver cr = context.getContentResolver(); cr.delete(CalendarContract.Events.CONTENT_URI, CalendarContract.Events.DESCRIPTION + "=\"com.metinkale.prayer\"", null); String id = Prefs.getCalendar(); if ("-1".equals(id) || (Prefs.getLanguage() == null)) { return; } int year = LocalDate.now().getYear(); Collection<int[]> days = new ArrayList<>(); days.addAll(HicriDate.getHolydays(year)); days.addAll(HicriDate.getHolydays(year + 1)); int i = 0; ContentValues[] events = new ContentValues[days.size()]; for (int[] date : days) { ContentValues event = new ContentValues(); event.put(CalendarContract.Events.CALENDAR_ID, id); event.put(CalendarContract.Events.TITLE, Utils.getHolyday(date[HicriDate.DAY] - 1)); event.put(CalendarContract.Events.DESCRIPTION, "com.metinkale.prayer"); ReadableInstant cal = new DateTime(date[HicriDate.GY], date[HicriDate.GM], date[HicriDate.GD], 0, 0, 0); long dtstart = cal.getMillis(); long dtend = dtstart + DateUtils.DAY_IN_MILLIS; event.put(CalendarContract.Events.DTSTART, dtstart + TimeZone.getDefault().getOffset(dtstart)); event.put(CalendarContract.Events.DTEND, dtend + TimeZone.getDefault().getOffset(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); events[i] = event; i++; } cr.bulkInsert(CalendarContract.Events.CONTENT_URI, events); } catch (Exception e) { Prefs.setCalendar("-1"); Crashlytics.logException(e); } }
From source file:com.metinkale.prayerapp.Utils.java
License:Apache License
static void init(@NonNull Context c) { String newLang = Prefs.getLanguage(); Crashlytics.setString("lang", newLang); Crashlytics.setString("digits", Prefs.getDigits()); int year = LocalDate.now().getYear(); if (year != Prefs.getLastCalSync()) { MainIntentService.startCalendarIntegration(c); Prefs.setLastCalSync(year);//w w w . j a v a 2 s . co m } if (newLang == null) { return; } Locale locale = new Locale(newLang); Configuration config = new Configuration(); Locale.setDefault(locale); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { config.setLocale(locale); } else { config.locale = locale; } c.getResources().updateConfiguration(config, c.getResources().getDisplayMetrics()); }
From source file:com.metinkale.prayerapp.vakit.fragments.MainFragment.java
License:Apache License
public void update() { if ((mTimes == null) || (mView == null)) { return;/* ww w .ja v a2 s.c o m*/ } mTitle.setText(mTimes.getName()); LocalDate greg = LocalDate.now(); HicriDate hijr = new HicriDate(greg); mHicri.setText(Utils.format(hijr)); mDate.setText(Utils.format(greg)); String[] daytimes = { mTimes.getTime(greg, 0), mTimes.getTime(greg, 1), mTimes.getTime(greg, 2), mTimes.getTime(greg, 3), mTimes.getTime(greg, 4), mTimes.getTime(greg, 5) }; boolean synced = false; for (int i = 0; i < 6; i++) { TextView time = (TextView) mView.findViewById(ids[i]); time.setText(Utils.fixTimeForHTML(daytimes[i])); if (!synced && daytimes[i].equals("00:00") && mTimes instanceof WebTimes && App.isOnline()) { ((WebTimes) mTimes).syncAsync(); synced = true; } } }
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 w w w. j a v a 2 s. c om*/ ((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.FaziletTimes.java
License:Apache License
@NonNull protected Builders.Any.F[] createIonBuilder() { String[] a = getId().split("_"); if (a.length < 4) { Crashlytics.setString("FAZILET_ID", getId()); Crashlytics.logException(new Exception("INVALID ID IN FAZILET")); this.delete(); return new Builders.Any.F[0]; }/* w w w .ja v a 2 s . co m*/ int country = Integer.parseInt(a[1]); int state = Integer.parseInt(a[2]); int city = Integer.parseInt(a[3]); LocalDate ldate = LocalDate.now(); int Y = ldate.getYear(); int M = ldate.getMonthOfYear(); return new Builders.Any.F[] { Ion.with(App.get()).load("http://www.fazilettakvimi.com/tr/namaz_vakitleri.html").setTimeout(3000) .setBodyParameter("ulke_id", "" + country).setBodyParameter("sehir_id", "" + state) .setBodyParameter("ilce_id", "" + city) .setBodyParameter("baslangic_tarihi", Y + "-" + az(M) + "-01") .setBodyParameter("bitis_tarihi", (Y + 5) + "-12-31") }; }
From source file:com.metinkale.prayerapp.vakit.times.IGMGTimes.java
License:Apache License
@NonNull protected Builders.Any.F[] createIonBuilder() { String path = getId().replace("nix", "-1"); String[] a = path.split("_"); int id = Integer.parseInt(a[1]); if (id <= 0 && a.length > 2) id = Integer.parseInt(a[2]); LocalDate ldate = LocalDate.now(); int rY = ldate.getYear(); int Y = rY;/*from ww w.j av a 2s . com*/ int m = ldate.getMonthOfYear(); final List<Builders.Any.B> queue = new ArrayList<>(); for (int M = m; (M <= (m + 2)) && (rY == Y); M++) { if (M == 13) { M = 1; Y++; } queue.add(Ion.with(App.get()).load( "http://www.igmg.org/wp-content/themes/igmg/include/gebetskalender_ajax.php?show_ajax_variable=" + id + "&show_month=" + (M - 1)) .setTimeout(3000)); } return queue.toArray(new Builders.Any.F[queue.size()]); }