Example usage for org.joda.time LocalDate getMonthOfYear

List of usage examples for org.joda.time LocalDate getMonthOfYear

Introduction

In this page you can find the example usage for org.joda.time LocalDate getMonthOfYear.

Prototype

public int getMonthOfYear() 

Source Link

Document

Get the month of year field value.

Usage

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];
        }//from   w  w  w .j  ava  2s  .co 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 {//from  w ww.  ja va  2  s  .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.ja va 2s.  com*/
            ((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);/* ww  w.j  ava 2 s .  c o m*/
    return times.get(time);
}

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];
    }/*ww  w .  j a  v a 2s  .  c om*/
    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 2 s. c om
    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()]);
}

From source file:com.metinkale.prayerapp.vakit.times.MalaysiaTimes.java

License:Apache License

@NonNull
protected Builders.Any.F[] createIonBuilder() {
    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;//from   w  w  w .  j a v a 2s .c o  m
    int m = ldate.getMonthOfYear();
    String[] split = getId().split("_");
    if (split.length < 3)
        delete();
    split[1] = URLEncoder.encode(split[1]);
    split[2] = URLEncoder.encode(split[2]);

    final List<Builders.Any.B> queue = new ArrayList<>();
    for (int M = m; (M <= (m + 1)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        queue.add(Ion
                .with(App.get()).load("http://www.e-solat.gov.my/web/waktusolat.php?negeri=" + split[1]
                        + "&state=" + split[1] + "&zone=" + split[2] + "&year=" + Y + "&jenis=year&bulan=" + M)
                .setTimeout(3000));
    }

    return queue.toArray(new Builders.Any.F[queue.size()]);
}

From source file:com.metinkale.prayerapp.vakit.times.MoroccoTimes.java

License:Apache License

@NonNull
protected Builders.Any.F[] createIonBuilder() {
    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;//from   w ww  . jav a  2  s.c  o m
    int m = ldate.getMonthOfYear();

    final List<Builders.Any.B> queue = new ArrayList<>();
    for (int M = m; (M <= (m + 1)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        queue.add(Ion.with(App.get()).load(
                "http://www.habous.gov.ma/prieres/defaultmois.php?ville=" + getId().substring(2) + "&mois=" + M)
                .setTimeout(3000));
    }

    return queue.toArray(new Builders.Any.F[queue.size()]);
}

From source file:com.metinkale.prayerapp.vakit.times.WebTimes.java

License:Apache License

private void cleanTimes() {
    Set<String> keys = new ArraySet<>();
    keys.addAll(times.keySet());// ww w.j  ava2  s.  c  om
    LocalDate date = LocalDate.now();
    int y = date.getYear();
    int m = date.getMonthOfYear();
    for (String key : keys) {
        int year = FastParser.parseInt(key.substring(0, 4));
        if (year < y)
            keys.remove(key);
        else if (year == y) {
            int month = FastParser.parseInt(key.substring(5, 7));
            if (month < m)
                keys.remove(key);
        }
    }

}

From source file:com.mycompany.ajaxandxml.ws.ReleasedAdapter.java

@Override
public String marshal(LocalDate v) throws Exception {
    return v.getYear() + "-" + v.getMonthOfYear() + "-" + v.getDayOfMonth();
}