question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: DatePicker shows wrong month

See original GitHub issue

Tell us about the problem

For 9th and 10th months DatePicker shows October.

screen shot 2017-09-19 at 6 12 10 pm

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.1.3
  • Cross-platform modules: 3.2.0
  • Runtime(s): 3.2.0
  • Genymotion Android 7.1.0 Samsung Galaxy S7

Please tell us how to recreate the issue in as much detail as possible.

Here is the repo demonstrating the bug: https://github.com/terreb/ns-datepicker

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

/app/main-page.xml

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
    <StackLayout>
        <DatePicker day="1" month="9" year="2017" verticalAlignment="center"/>
        <DatePicker day="1" month="10" year="2017" verticalAlignment="center"/>
    </StackLayout>
</Page>

/app/App_Resources/Android/values-v21/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- Application theme -->
    <style name="AppTheme" parent="AppThemeBase">
        <item name="android:datePickerStyle">@style/SpinnerDatePicker</item>
        <item name="android:timePickerStyle">@style/SpinnerTimePicker</item>
    </style>

    <!-- Default style for DatePicker - in spinner mode -->
    <style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
        <item name="android:datePickerMode">spinner</item>
    </style>

    <!-- Default style for TimePicker - in spinner mode -->
    <style name="SpinnerTimePicker" parent="android:Widget.Material.Light.TimePicker">
        <item name="android:timePickerMode">spinner</item>
    </style>

    <style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
        <item name="android:elevation">4dp</item>
    </style>
</resources>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
terrebcommented, Oct 20, 2017

Hi @vakrilov, thank you for the explanation and I confirm the issue is fixed after I changed to “tns-core-modules”: “3.3.0-2017-10-18-3”.

1reaction
terrebcommented, Oct 19, 2017

Hi @tsonevn, are you kidding? Do you really think that September is 9th month (no problem here) and November is 10th?! Should I set

<DatePicker day="1" month="9.5" year="2017" verticalAlignment="center"/>

for October then;)

Read more comments on GitHub >

github_iconTop Results From Across the Web

DatePicker shows wrong value of month - Stack Overflow
In Android, when you select a date from the date picker, it starts counting the months from 0. So, this means that the...
Read more >
[Solved]-DatePicker in Kotlin showing wrong month-kotlin
Coding example for the question DatePicker in Kotlin showing wrong month-kotlin.
Read more >
Pickers | Android Developers
Android provides controls for the user to pick a time or pick a date as ready-to-use dialogs. Each picker provides controls for selecting ......
Read more >
DatePicker Tutorial With Example In Android Studio
In Android, DatePicker is a widget used to select a date. It allows to select date by day, month and year in your...
Read more >
Date picker is showing wrong dates on Android app.
Hi,. My calendar looks funny on the mobile app. It is mismatching dates with the weekdays for the current month. It is showing,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found