B4J Question .MinYear using PreferencesDialog

Mahares

Expert
Licensed User
Longtime User
how do you set the .MinYear using PreferencesDialog with "type": "Date"
Year cannot be before jan 1, 2019
B4X:
Private minyear As String = "2019"

'Date cannot be before jan 1, 2019
Sub Pref_IsValid (TempData As Map) As Boolean
    Dim x As Long =DateTime.dateparse("1/1/" & minyear)
    Dim d As Long = TempData.GetDefault("Date", DateTime.Now)
    If d < x Then
        prefdialog.ScrollToItemWithError("Date")
        Return False
    End If
    Return True
End Sub
 
Upvote 0

Angelo Messina

Active Member
Licensed User
Longtime User
Dim y As Long = DateTime.DateParse( "01/01/" & "1950")


java.text.ParseException: Unparseable date: "01/01/1950"


Thanks for your kind reply

but I have to manage smaller dates than 1960
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
but I have to manage smaller dates than 1960
The B4XPreferenceDialog date is based on the B4XDateTemplate class located in the XUI Views library. It defaults to a minum year of 1970, but you can change it in your code by adding this line
B4X:
Private minyear As String 

prefdialog.DateTemplate.MinYear =1950   'add this line so you can navigate beyond 1970
minyear ="1960"
'then use the year you want to limit your dates
 
Upvote 0
Top