Coder Social home page Coder Social logo

singledateandtimepicker's Introduction

SingleDateAndTimePicker

How to use

  • use like your module lib android
  1. init :
 SingleDateAndTimePickerDialog.Builder singleBuilder;
  1. create and show
       SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        String currentDateandTime = sdf.format(new Date());
        SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy");
        Date dateObj = null;
        try {
            dateObj = curFormater.parse(currentDateandTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }


//        final Calendar calendar = Calendar.getInstance();
//        calendar.set(Calendar.DAY_OF_MONTH, 10);
//        calendar.set(Calendar.MONTH, 1);
//        calendar.set(Calendar.YEAR, 2014);
//        calendar.set(Calendar.HOUR_OF_DAY, 12);
//        calendar.set(Calendar.MINUTE, 13);
//
//        final Date defaultDate = calendar.getTime();

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
        final SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());

        singleBuilder = new SingleDateAndTimePickerDialog.Builder(MainActivity.this)
                .bottomSheet()
                .curved()

                //.backgroundColor(Color.BLACK)
                .mainColor(getResources().getColor(R.color.colorAccent))

                .displayHours(false)
                .displayMinutes(false)
                .displayDays(false)

                .displayMonth(true)
                .displayDaysOfMonth(true)
                .displayYears(true)
                .displayMonthNumbers(true)

                //.mustBeOnFuture()

                //.minutesStep(15)
                //.mustBeOnFuture()
                .defaultDate(dateObj)
                // .minDateRange(minDate)
                // .maxDateRange(maxDate)

                .displayListener(new SingleDateAndTimePickerDialog.DisplayListener() {
                    @Override
                    public void onDisplayed(SingleDateAndTimePicker picker) {

                    }
                })
                .title("Hủy")
                .listener(new SingleDateAndTimePickerDialog.Listener() {
                    @Override
                    public void onDateSelected(Date date) {

                        tvdate.setText(simpleDateFormat.format(date));

                    }
                });
        singleBuilder.display();
  1. Documenation https://github.com/florent37/SingleDateAndTimePicker

singledateandtimepicker's People

Contributors

tusinh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.