DateTime.DateParse(datestring) will throw an exception if parsing fails, which you could trap with extra coding, but I don't see a method for what your looking for. Perhaps you should suggest it on the Bugs & Wishlist forum? It may be included in one of the third party libraries, but a site search didn't turn up anything.
The best approach is to try to parse and catch the error:
B4X:
Sub Activity_Create(FirstTime As Boolean)
DateTime.DateFormat = "dd/mm/yy"
Log(IsValidDate("01/01/2000"))
Log(IsValidDate("13-12/2007"))
End Sub
Sub IsValidDate(Date As String) As Boolean
Try
DateTime.DateParse(Date)
Return True
Catch
Return False
End Try
End Sub
However, currently the date parser will only throw an error if the string is not formatted correctly. It will not throw an error for "out of range" dates: 35/01/2000
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.