B4J Question Alternatives for capturing pre-1970 dates?

cjpryor

Active Member
Licensed User
I want my application to be as cross-platform as possible with limited platform specific code. I used B4XDialog + B4XDateTemplate from XUI Views library to capture, display, store, and retrieve dates in my B4J application. It is working well.

However, I have two issues with this current approach:

1) I would like an easy way for customers to choose between selecting dates from a popup OR manually entering their dates (with format checking).

2) My application needs to capture dates prior to 12/31/1969. I watched the Date Time training video and realize that ticks begin on midnight 12/31/1969 so that is a limiting factor. I was hoping negative ticks would be allowed but apparently not.

So, what alternatives do I have? I suppose I could use a text field that I validate with in-line Java code but I'm not sure how I would implement a graphic date picker with this approach and I am wondering what else I should consider before I go down that path.

Thanks!
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I was hoping negative ticks would be allowed but apparently not.
why not?

did a test and worked with negative ticks.
1623804054023.png
 
Upvote 0

cjpryor

Active Member
Licensed User
That’s good news. I’ll have to take another look at the B4XDialog + B4XDateTemplate from XUI Views library configurations. Using the default configurations, I could not select a date earlier than Jan 1, 1970 so I jumped to the wrong conclusion that negative ticks were not allowed.

Any suggestions on how to allow users to directly type in a date (with format checking)? Perhaps I can modify the B4XDateTemplate to add a field for direct date entry?

Thanks again.
 
Upvote 0

cjpryor

Active Member
Licensed User
Found the setting to go back prior to 1970!

B4X:
DateTemplate.MinYear=1600

Still looking for advice on direct date entry bypassing the template. :)
 
Last edited:
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi!
May be this will help you.
 
Upvote 0

cjpryor

Active Member
Licensed User
Thanks Erel. I jumped to the wrong conclusion based on the default configuration of the DateTemplate. I then discovered the .MinYear attribute of the DateTemplate that allows me to enable selection of years earlier than 1970.

Is there a simple way to allow a user to directly type a date into a DateTemplate field? I like the ability to select a date using the date picker functionality but would also like to allow users to directly type in their date into the DateTemplate field.

Thanks!
 
Upvote 0

cjpryor

Active Member
Licensed User
I decided just to go old school. I added a text field for displaying/entering the date and then made the DateTemplate swift button optional. If it is used it simply updates the text field rather than the text of the swiftbutton. I simply used DateTime.DateParse for the validation and popup a xui.MsgboxAsync if there is a problem. Here is a screen capture of that portion of my ui. Of course these are made up dates and it is highly likely in some situations all that will be needed is the year but that is a different question. BTW, it would be nice if I could make the swiftbutton look more like a button but this is the closest I have been able to get it so far. The "x" button was originally used to clear the DateTemplate but may be unnecessary with this new approach.


date.png
 
Upvote 0
Top