Mark said:
That's a function in the webservice that I have introduced (we wrote the
webservice). It just means the webservice delivers the date string that way.
Ahh, I see now. I thought you consume the String from the
service. Now it's clear.
I believe that yyyy-MM-dd will always be interpreted by .Net as yyyy-MM-dd
regardless of whether the local user has US (MM-DD-YYYY) or New Zealand
(DD-MM-YYYY) date format set in their control panel. The same doesn't apply
for "07/07/2009".
My lead programmer used datetime strings since he is returning webservice
values pipe-separated with an asterisk for end of record:
3|2009-09-07 12:00:00 a.m.|2009-09-12 12:00:00
a.m.|True||24|4320|||2008-10-05 12:00:00 a.m.||Joe|Smith*
7|2009-09-07 12:00:00 a.m.|2009-09-12 12:00:00
a.m.|True||7200|7200|||2009-02-07 12:00:00 a.m.||Mary|Brown*
11|2009-09-07 12:00:00 a.m.|2009-09-12 12:00:00
a.m.|True||60|7200|||2009-02-07 12:00:00 a.m.||Ken|Jones*
He said there was no need to use XML. I'm not 100% sure that's the best
practice though he's the computer science grad.
I had thought of using 37098.4323 format for the date but don't mind being
able to see the values without needing to convert them as above.
I haven't written and used a web service so far, so I think someone else
could help you better. Though, with XML it would not have been a problem
because there is a default conversion from/to String if the data type
(DateTime) is known.
But anyway, before now, it wasn't clear to me that there are actually
two issues: a) The date/time format b) the time zone. The time zone is
not returned from the web service. Without this information, any
application consuming the service would have to either guess or know it,
which means hard-coding it. If the web service' local time zone is not
of interest, there must be a agreement which time zone it is. Only UTC
makes sense, IMO. So, if the consumers know that it's UTC, they can
easily convert from that time zone to their local time zones.
I thought I might get an error if the incoming dtRawDate was Null.
Ok, but in that case I'd at least restrict it at runtime. Something like
shared Function fWsDateFormat(ByVal dtRawDate As Object) As String
'Convert date time to standardized string
'---------------------------------------------
Dim strDateTimeStringFormat As String = "yyyy-MM-dd hh:mm:ss tt"
if dtRawDate is dbnull.value then
Return ""
elseif typeof dtRawDate is datetime then
Return dtRawDate.tostring(strDateTimeStringFormat)
else
'throw exception here
End If
End Function
In addition a Nullable(of DateTime) could be used.
Well, only a side note.