B4J Question B4XPreferencesDialog - issue with date field and custom DateFormat

Drago Bratko

Member
Licensed User
Example code here :
B4X:
DateTime.DateFormat = "dd.MM.YYYY"
   
pdPaket.Initialize(MainForm.RootPane, "Paket", 300dip, 300dip)
pdPaket.LoadFromJson(File.ReadString(File.DirAssets, "Paket.json"))
pdPaket.DateTemplate.FirstDay = 1
   
Private oPaket As Map
oPaket.Initialize
oPaket.Put("dOd", DateTime.Now)
oPaket.Put("dDo", DateTime.Add(DateTime.Now, 1, 0, 0))
Wait For (pdPaket.ShowDialog(oPaket, "Dodaj", "Odbaci")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
    Log(oPaket)
    Log(DateTime.Date(oPaket.Get("dOd")))
    Log(DateTime.Date(oPaket.Get("dDo")))
End If
If I comment line where date format is set (DateTime.DateFormat = "dd.MM.YYYY"), then all is fine.
If this line is executed, then selected dates are not transfered properly … attached is small example project.

Any ideas ?
 

Attachments

Harris

Expert
Licensed User
DateTime.DateFormat = "dd.MM.YYYY"
Try: DateTime.DateFormat = "dd.MM.yyyy" ' lowercase year

Failing that:

Try DateTime.DateFormat = "yyyy.MM.dd" ' (year, month, day)

The DateTime.Add ( expects: Ticks as long, Years, Months, Days as Int )
 
Top