Hi,
To format dates, I use this code:
If the date now is "2022-09-04 18:58:20.34" this gives me this:
tmp = "2022-09-04 18:58:20.34"
myDate = "09-04"
That's all fine.
The problem is with my SQLite database. The column is called DueDate, it's TEXT type and the date in it stored like this:
row1>>>"2020-03-01 15:28:30.13"
You can see that the date format is "YYYY-MM-DD HH:MM:SS.SS"
I use this code to format it:
This gives me this:
tmp = "2020-03-01 15:28:30.13" << read from the database correctly
myDate = "" <<< Gives out the following error:
java.lang.NumberFormatException: For input string: "2020-03-01 15:28:30.13"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
But I expect it to give me this:
tmp = "2020-03-01 15:28:30.13"
myDate= "03-01"
Help me please. Thanks.
To format dates, I use this code:
B4X:
1. DateTime.DateFormat = "MM-dd"
2. Dim tmp As String = DateTime.Now
3. Dim myDate As String = DateTime.Date(tmp)
If the date now is "2022-09-04 18:58:20.34" this gives me this:
tmp = "2022-09-04 18:58:20.34"
myDate = "09-04"
That's all fine.
The problem is with my SQLite database. The column is called DueDate, it's TEXT type and the date in it stored like this:
row1>>>"2020-03-01 15:28:30.13"
You can see that the date format is "YYYY-MM-DD HH:MM:SS.SS"
I use this code to format it:
B4X:
1. DateTime.DateFormat = "MM-dd"
2. Dim tmp As String = Cursor1.GetString("DueDate")
3. Dim myDate As String = DateTime.Date(tmp)
This gives me this:
tmp = "2020-03-01 15:28:30.13" << read from the database correctly
myDate = "" <<< Gives out the following error:
java.lang.NumberFormatException: For input string: "2020-03-01 15:28:30.13"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
But I expect it to give me this:
tmp = "2020-03-01 15:28:30.13"
myDate= "03-01"
Help me please. Thanks.