All Projects → dewinjm → monthyear-picker

dewinjm / monthyear-picker

Licence: Apache-2.0 license
Month and Year picker library for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to monthyear-picker

Calendarview
An Easy to Use Calendar for iOS (Swift 5.0)
Stars: ✭ 429 (+1161.76%)
Mutual labels:  datepicker, date-picker
Vuejs Datepicker
A simple Vue.js datepicker component. Supports disabling of dates, inline mode, translations
Stars: ✭ 2,529 (+7338.24%)
Mutual labels:  datepicker, date-picker
Jtsage Datebox
A multi-mode date and time picker for Bootstrap (3&4), jQueryMobile, Foundation, Bulma, FomanticUI, and UIKit (or others)
Stars: ✭ 481 (+1314.71%)
Mutual labels:  datepicker, date-picker
angular-eonasdan-datetimepicker
A wrapper directive around the Eonasdan Datepicker v4 component.
Stars: ✭ 63 (+85.29%)
Mutual labels:  datepicker, date-picker
Datepicker
Get a date with JavaScript! A datepicker with no dependencies.
Stars: ✭ 212 (+523.53%)
Mutual labels:  datepicker, date-picker
vue-single-date-picker
A Vue project - single date picker
Stars: ✭ 16 (-52.94%)
Mutual labels:  datepicker, date-picker
React Nice Dates
A responsive, touch-friendly, and modular date picker library for React.
Stars: ✭ 924 (+2617.65%)
Mutual labels:  datepicker, date-picker
flutter date picker timeline
Gregorian and Jalali customizable date picker as a horizontal timeline
Stars: ✭ 29 (-14.71%)
Mutual labels:  datepicker, date-picker
Date Picker
Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
Stars: ✭ 1,325 (+3797.06%)
Mutual labels:  datepicker, date-picker
Angular Mydatepicker
Angular datepicker and date range picker 📅
Stars: ✭ 76 (+123.53%)
Mutual labels:  datepicker, date-picker
vuejs3-datepicker
vue 3 datepicker. supports disabling, highlighting of dates and programmatic access of date.
Stars: ✭ 23 (-32.35%)
Mutual labels:  datepicker, date-picker
Ngx Mydatepicker
Angular 2+ attribute directive datepicker
Stars: ✭ 123 (+261.76%)
Mutual labels:  datepicker, date-picker
DatePicker
html价格日历控件
Stars: ✭ 21 (-38.24%)
Mutual labels:  datepicker, date-picker
Angular Datepicker
Highly configurable date picker built for Angular applications
Stars: ✭ 386 (+1035.29%)
Mutual labels:  datepicker, date-picker
s-date-range-picker
📅 A date range picker built with Svelte
Stars: ✭ 13 (-61.76%)
Mutual labels:  datepicker, date-picker
Mydatepicker
Angular 2+ date picker
Stars: ✭ 558 (+1541.18%)
Mutual labels:  datepicker, date-picker
react-calendar
A no dependencies, lightweight and feature-rich ⚡ calendar component for react.
Stars: ✭ 68 (+100%)
Mutual labels:  datepicker, date-picker
Vue Mj Daterangepicker
🗓Vue.js date range picker with multiples ranges and presets (vue 2.x)
Stars: ✭ 48 (+41.18%)
Mutual labels:  datepicker, date-picker
Datepicker
仿滴滴出行预约打车IOS风格3D时间选择器 🌲
Stars: ✭ 118 (+247.06%)
Mutual labels:  datepicker, date-picker
nepali-date-picker
Nepali Date Picker jQuery Plugin 🇳🇵
Stars: ✭ 71 (+108.82%)
Mutual labels:  datepicker, date-picker

Month and Year Picker

API jitpack Build Status

Month and Year picker library for Anndroid

Simple Picker With ranges Picker
Simple Picker With ranges Picker

Example

Show MonthYear-picker in a simple way

int yearSelected;
int monthSelected;

//Set default values
Calendar calendar = Calendar.getInstance();
yearSelected = calendar.get(Calendar.YEAR);
monthSelected = calendar.get(Calendar.MONTH);

MonthYearPickerDialogFragment dialogFragment = MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected);
                
dialogFragment.show(getSupportFragmentManager(), null);

Listening changes in values

dialogFragment.setOnDateSetListener(new MonthYearPickerDialog.OnDateSetListener() {
  @Override
  public void onDateSet(int year, int monthOfYear) {
    // do something
  }
});

Show with Ranges

Note: the values of the ranges are in milliseconds.

The monthOfYear value is 0 for the first month and the last is 11, (0 = January, 11= December).

// Use the calendar for create ranges
Calendar calendar = Calendar.getInstance();

calendar.clear();
calendar.set(2010, 0, 1); // Set minimum date to show in dialog
long minDate = calendar.getTimeInMillis(); // Get milliseconds of the modified date

calendar.clear();
calendar.set(2018, 11, 31); // Set maximum date to show in dialog
long maxDate = calendar.getTimeInMillis(); // Get milliseconds of the modified date

// Create instance with date ranges values        
MonthYearPickerDialogFragment dialogFragment =  MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, minDate, maxDate);
                
dialogFragment.show(getSupportFragmentManager(), null);

Custom title

By default the title will be the selected date. If you want to customize dialog title, add the additional custom title parameter:

String customTitle = "Your Custom Title";
MonthYearPickerDialogFragment dialogFragment = null;

//Simple way
dialogFragment = MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, customTitle);

// or with date ranges:
dialogFragment =  MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, minDate, maxDate, customTitle);
		
dialogFragment.show(getSupportFragmentManager(), null);

Month name format

By default the months names format will short. If you want to use a specific format , add the MonthFormat parameter:

MonthFormat monthFormat = MonthFormat.LONG; //MonthFormat.LONG or MonthFormat.SHORT
//Simple way
dialogFragment = MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, customTitle, monthFormat);

//With date ranges:
dialogFragment =  MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, minDate, maxDate, customTitle, monthFormat);

Accept specify Locale.

If you want to use a specific Locale , add the Locale parameter into the constructions:

Locale locale = new Locale("en-US");

//Simple way
dialogFragment = MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, customTitle, locale);

//With date ranges:
dialogFragment =  MonthYearPickerDialogFragment
                .getInstance(monthSelected, yearSelected, minDate, maxDate, customTitle, locale);

Download

Add the repository to your project build.gradle:

repositories {
  jcenter()
  maven {
    url "https://jitpack.io"
  }
}

And add the library to your module build.gradle:

dependencies {
  implementation 'com.github.dewinjm:monthyear-picker:1.0.2'
}

License

Copyright 2018 Dewin J. Martínez
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].