DateTimeRangePicker

Additional

Language
Kotlin
Version
v1.3 (Feb 21, 2017)
Created
Dec 20, 2016
Updated
Nov 6, 2017
Owner
SkedGo (skedgo)
Contributor
Thuy Trinh (thuytrinh)
1
Activity
Badge
Generate
Download
Source code

Blurb

DateTimeRangePicker

A date time range picker for android

Usage

Firstly, grab latest release of the library via JitPack. And note that, it utilizes Joda-Time to process some date time logic under the hood. So you might need to set up Joda-Time properly.

With start and end date times specified:

val intent = DateTimeRangePickerActivity.newIntent(
    context,
    TimeZone.getDefault(),
    DateTime.now().millis,
    DateTime.now().plusDays(2).millis
)
activity.startActivityForResult(intent, RQC_PICK_DATE_TIME_RANGE)

Or without start and end date times:

val intent = DateTimeRangePickerActivity.newIntent(
    context,
    TimeZone.getDefault(),
    null, null
)
activity.startActivityForResult(intent, RQC_PICK_DATE_TIME_RANGE)

At onActivityResult(), DateTimeRangePickerActivity will return an Intent data having following:

  • startTimeInMillis as Long
  • endTimeInMillis as Long
  • timeZone as String

Demo

Run 2 following instrumentation tests on DateTimeRangePickerActivityTest to see the 2 usages:

  • withoutStartAndEndDateTimes()
  • withStartAndEndDateTimes()