{"id":13643509,"url":"https://github.com/Kunzisoft/Android-SwitchDateTimePicker","last_synced_at":"2025-04-21T01:32:54.840Z","repository":{"id":47235545,"uuid":"69049275","full_name":"Kunzisoft/Android-SwitchDateTimePicker","owner":"Kunzisoft","description":"Android library for Date and Time Picker in same dialog","archived":false,"fork":false,"pushed_at":"2021-09-07T15:50:48.000Z","size":4877,"stargazers_count":383,"open_issues_count":10,"forks_count":89,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-13T04:09:36.569Z","etag":null,"topics":["android","datepicker","datetime-picker","dialog","fragment","timepicker"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kunzisoft.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-23T18:08:56.000Z","updated_at":"2025-02-15T18:48:11.000Z","dependencies_parsed_at":"2022-09-17T06:43:13.569Z","dependency_job_id":null,"html_url":"https://github.com/Kunzisoft/Android-SwitchDateTimePicker","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunzisoft%2FAndroid-SwitchDateTimePicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunzisoft%2FAndroid-SwitchDateTimePicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunzisoft%2FAndroid-SwitchDateTimePicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunzisoft%2FAndroid-SwitchDateTimePicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kunzisoft","download_url":"https://codeload.github.com/Kunzisoft/Android-SwitchDateTimePicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249982653,"owners_count":21355737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","datepicker","datetime-picker","dialog","fragment","timepicker"],"created_at":"2024-08-02T01:01:48.591Z","updated_at":"2025-04-21T01:32:51.563Z","avatar_url":"https://github.com/Kunzisoft.png","language":"Java","readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwitchDateTimePicker-blue.svg?style=flat)](http://android-arsenal.com/details/1/4513)\n\n# Android SwitchDateTime Picker\n\n\u003cimg src=\"https://raw.githubusercontent.com/Kunzisoft/Android-SwitchDateTimePicker/master/art/logo.png\"\u003e SwitchDateTime Picker is a library for select a *Date* object in dialog with a DatePicker (Calendar) and a TimePicker (Clock) in the same UI.\n\n\u003cimg src=\"https://raw.githubusercontent.com/Kunzisoft/Android-SwitchDateTimePicker/master/art/demo2.gif\" width=\"500\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/Kunzisoft/Android-SwitchDateTimePicker/master/art/demo1.gif\" width=\"320\"\u003e\n\n## Contributions\n\nYou can contribute in different ways to help us on our work.\n\n* Add features by a pull request.\n* Help to translate into your language\n* [Donate](https://www.kunzisoft.com/donation)  人◕ ‿‿ ◕人Y for a better service and a quick development of your features.\n\n## Installation\nAdd the JitPack repository in your build.gradle at the end of repositories:\n```\n\tallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url \"https://jitpack.io\" }\n\t\t}\n\t}\n```\nAnd add the dependency\n[![](https://jitpack.io/v/Kunzisoft/Android-SwitchDateTimePicker.svg)](https://jitpack.io/#Kunzisoft/Android-SwitchDateTimePicker)\n*replacing ${version} with the version number in jitpack*\n\n```\n\tdependencies {\n\t        compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:${version}'\n\t}\n```\n\n## Usage\n\n### SimpleDateFormat for Day and Month\nYou can specify a particular [*SimpleDateFormat*](https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) for value of Day and Month with **setSimpleDateMonthAndDayFormat(SimpleDateFormat format)**\nWarning, the format must satisfy the regular expression : **(M|w|W|D|d|F|E|u|\\s)***\n, for example *dd MMMM*\n\n### 24 Hours mode\nBy default, time is in 12 hours mode, If you want a 24-hour display, use:\n`dateTimeFragment.set24HoursMode(true);`\nbefore the \"show\"\n\n#### Hightligh selected AM / PM\nIn 24 hours mode, If you want to highlight the selected AM or PM, use :\n`dateTimeFragment.setHighlightAMPMSelection(true);`\n\n### Start with a specific view\nFor launch Dialog with a specific view, call :\n`dateTimeFragment.startAtTimeView();`, `dateTimeFragment.startAtCalendarView();` or `dateTimeFragment.startAtYearView();`\nbefore the \"show\"\n\n### Define minimum and maximum\nFor just allow selection after or/and before dates, use :\n`dateTimeFragment.setMinimumDateTime(Date minimum);`\nand\n`dateTimeFragment.setMaximumDateTime(Date maximum);`\n\n### TimeZone\nOptionally define a timezone :\n`dateTimeFragment.setTimeZone(TimeZone.getDefault());`\n\n### Style\nYou can customize the style to change color, bold, etc... of each element.\nYou need to use a Theme.AppCompat theme (or descendant) with SwitchDateTime's activity. (`compile 'com.android.support:appcompat-v7:25.1.0'` in gradle)\n\n\u003cimg src=\"https://raw.githubusercontent.com/Kunzisoft/Android-SwitchDateTimePicker/master/art/screen2.jpg\" width=\"320\"\u003e\n\nIn your *styles.xml*, you can redefine each style separately, but you must keep each item, for example : change size of \"year label\"\n```\n\u003cresources\u003e\n    \u003c!-- Base application theme. --\u003e\n    \u003cstyle name=\"MyAppCustomTheme\" parent=\"Theme.AppCompat.Light\"\u003e\n        \u003c!-- Customize your theme here. --\u003e\n        \u003citem name=\"colorPrimary\"\u003e@color/colorPrimary\u003c/item\u003e\n        \u003citem name=\"colorPrimaryDark\"\u003e@color/colorPrimaryDark\u003c/item\u003e\n        \u003citem name=\"colorAccent\"\u003e@color/colorAccent\u003c/item\u003e\n    \u003c/style\u003e\n\n    \u003c!-- SwitchDateTime style is independent, each element is optional--\u003e\n    \u003c!-- Year Precise --\u003e\n    \u003cstyle name=\"Theme.SwitchDateTime.DateLabelYear\"\u003e\n        \u003citem name=\"android:textSize\"\u003e58sp\u003c/item\u003e\n        \u003citem name=\"android:textColor\"\u003e#fff\u003c/item\u003e\n        \u003citem name=\"android:textStyle\"\u003ebold\u003c/item\u003e\n    \u003c/style\u003e\n\u003c/resources\u003e\n\n```\nStyles elements : https://github.com/Kunzisoft/Android-SwitchDateTimePicker/blob/master/switchdatetime/src/main/res/values/styles.xml\n\n#### AlertStyle\nTo customize the AlertDialog that is shown, use :\n`void setAlertStyle(@StyleRes int styleId)`\n\n### Sample\nYou can see\nhttps://github.com/J-Jamet/Android-SwitchDateTimePicker/blob/master/sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java\nfor complete sample.\n```\n// Initialize\nSwitchDateTimeDialogFragment dateTimeDialogFragment = SwitchDateTimeDialogFragment.newInstance(\n        \"Title example\",\n        \"OK\",\n        \"Cancel\"\n);\n\n// Assign values\ndateTimeDialogFragment.startAtCalendarView();\ndateTimeDialogFragment.set24HoursMode(true);\ndateTimeDialogFragment.setMinimumDateTime(new GregorianCalendar(2015, Calendar.JANUARY, 1).getTime());\ndateTimeDialogFragment.setMaximumDateTime(new GregorianCalendar(2025, Calendar.DECEMBER, 31).getTime());\ndateTimeDialogFragment.setDefaultDateTime(new GregorianCalendar(2017, Calendar.MARCH, 4, 15, 20).getTime());\n\n// Define new day and month format\ntry {\n    dateTimeDialogFragment.setSimpleDateMonthAndDayFormat(new SimpleDateFormat(\"dd MMMM\", Locale.getDefault()));\n} catch (SwitchDateTimeDialogFragment.SimpleDateMonthAndDayFormatException e) {\n    Log.e(TAG, e.getMessage());\n}\n\n// Set listener\ndateTimeDialogFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonClickListener() {\n    @Override\n    public void onPositiveButtonClick(Date date) {\n        // Date is get on positive button click\n        // Do something\n    }\n\n    @Override\n    public void onNegativeButtonClick(Date date) {\n        // Date is get on negative button click\n    }\n});\n\n// Show\ndateTimeDialogFragment.show(getSupportFragmentManager(), \"dialog_time\");\n```\n\n#### Neutral button\n\n\u003cimg src=\"https://raw.githubusercontent.com/Kunzisoft/Android-SwitchDateTimePicker/master/art/screen3.jpg\" width=\"320\"\u003e\n\nTo use with a neutral button, initialize with another parameter and implement the *OnButtonWithNeutralClickListener* :\n```\nSwitchDateTimeDialogFragment dateTimeDialogFragment = SwitchDateTimeDialogFragment.newInstance(\n        \"Title example\",\n        \"OK\",\n        \"Cancel\",\n        \"Clean\"\n);\n\ndateTimeFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonWithNeutralClickListener() {\n    @Override\n    public void onPositiveButtonClick(Date date) {\n    }\n\n    @Override\n    public void onNegativeButtonClick(Date date) {\n    }\n\n    @Override\n    public void onNeutralButtonClick(Date date) {\n    }\n});\n```\n\n## Bonus\nYou can follow the project live on https://www.livecoding.tv/kunzisoft/\n\n## License\n\nCopyright (c) 2016 JAMET Jeremy\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["日历时间"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKunzisoft%2FAndroid-SwitchDateTimePicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKunzisoft%2FAndroid-SwitchDateTimePicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKunzisoft%2FAndroid-SwitchDateTimePicker/lists"}