B4J Question B4XPreferencesDialog - issue with date field and custom DateFormat

Discussion in 'B4J Questions' started by Drago Bratko, Apr 29, 2019.

  1. Drago Bratko

    Drago Bratko Member Licensed User

    Example code here :
    Code:
    DateTime.DateFormat = "dd.MM.YYYY"
       
    pdPaket.Initialize(MainForm.RootPane, 
    "Paket"300dip300dip)
    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, 100))
    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 ?
     

    Attached Files:

  2. Harris

    Harris Well-Known Member Licensed User

    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 )
     
    Erel and Drago Bratko like this.
  3. Drago Bratko

    Drago Bratko Member Licensed User

    Lowercase year did a trick … :) … thank you. It works now.
     
    Harris likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice