XML dateformat

sigster

Active Member
Licensed User
Longtime User
Hi

I am try to format the date so I only see the date
Like 18-07-2012

I get this error

java.text.ParseException: Unparseable date: "2012-07-18T10:46:36" (at offset 4)

B4X:
<dagsetning>2012-07-18T10:46:36</dagsetning>

B4X:
         Else If Name = "dagsetning" Then
         
            Dim data As Long
            data = DateTime.DateParse(Text.ToString) 
            'DateTime.DateFormat = "yyyy-MM-dd"
            DateTime.DateFormat ="MM/dd/yyyy"
            Dim DateString As String
            dagsetning_titill = DateTime.date(data)

           End If

Regards
Sigster
 

corwin42

Expert
Licensed User
Longtime User
For parsing a datestring you have to set the correct dateformat:

B4X:
Dim data As Long
Dim datestring as String

DateTime.DateFormat = "yyyy-MM-dd'T'HH:mm:ss"
data = DateTime.DateParse(Text.ToString) 

DateTime.DateFormat = "yyyy-MM-dd"
datestring = DateTime.date(data)
 
Upvote 0

sigster

Active Member
Licensed User
Longtime User
Thanks corwin42 Erel

this is what I was doing
this is the currency list I was reading online "xml" and I add the image from DirAssets





Regards
Sigster
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…