Default Device Date Format Problem

LisaM

Member
Licensed User
Longtime User
Hi Guys,
I have an app i released on the play store and a few people are coming back with a problem that did not show up in testing.

What happens is the user enters a start date into a dialog box they are instructed to enter that date as MM/dd/yyyy.

I then use this date and compare it against DateTime.Date(DateTime.Now) and then plus or minus a day or two if the statement is True then i display certain information into labels.

This is an example of the code for displaying the Info:
B4X:
Sub SetWorkout
   Dim SetDate As String
   SetDate = cd
   If DateTime.Date(DateTime.Now) = SetDate Then
      lblWDis.Text = "Fit Test"
      lblPhase.Text = "1"
      lblDurDis.Text = "00:25:38"
   End If
   If DateTime.Date(DateTime.Now - 1 * DateTime.TicksPerDay) = SetDate Then
      lblWDis.Text = "Plyometric Cardio Circuit"
      lblPhase.Text = "1"
      lblDurDis.Text = "00:41:47"
   End If
   If DateTime.Date(DateTime.Now - 2 * DateTime.TicksPerDay) = SetDate Then
      lblWDis.Text = "Cardio Power & Resistance"
      lblPhase.Text = "1"
      lblDurDis.Text = "00:39:19"
   End If
End Sub

On 90% of devices this works but i found a device that it does not work on and i created a label to display
B4X:
DateTime.DeviceDefaultDateFormat
and this shows as MMM d,y even though under android's date & time settings the date format is set to 01/17/2013 (MM/dd/yyyy).

How do I fix this?

:confused:
 

LisaM

Member
Licensed User
Longtime User
I tried setting
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
before running the rest of the code but this did not work.

Is that what you were refering to?...Thanks for the quick reply :D
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
What do you get logging the DateTime.Date(DateTime.Now - 1 * DateTime.TicksPerDay) after using the dateFormat? :)
 
Upvote 0

LisaM

Member
Licensed User
Longtime User
OMG, the emulator I was using if I used the "/" from the symbols menu then it created a space between the numbers but if I use the "/" from the "1" button then there was no space and it worked.

Still I am confused as to why other people are having problems.

Thanks for your help sorry it was something so silly in the end.
 
Upvote 0
Top