Date/time 'tostring' problem

  • Thread starter Thread starter Glyn Meek
  • Start date Start date
G

Glyn Meek

One line of our code is as follows...

xml_node.Attributes(2).Value =
Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz")

When we have the Pocket PC Regional Settings set to U.S. or England or
pretty much anywhere except Italy, this would result in something like...

"2004-10-24T12:25:00.9687500-05:00"

being generated by the Now.ToString, which is perfect (i.e. colons between
the hours, minutes andseconds of the 'time' part of the field)...BUT, if we
have the Pocket PC with a regional setting for Italy, this does NOT work
correctly. The Italian setting would normally set the 'time' to 12.25.00
instead of 12:25:00, but we assumed that the ToString literal would force
the colons : to be insrted...IT DOESN'T and instead, we get...

"2004-10-24T12.25.00.9687500-05:00"

Where we now have periods between the hours, minutes andseconds of the
'time' part of the field

Can anyone tell us what's going on here and how we can force the : to
appear. The problem maifests itself when we bring the xml file that this is
a part of back to the PC where the PC rejects the date/time format, EVEN IF
THE PC IS RUNNING WITH AN ITALY SETTING!!!

Regards

Glyn Meek

SoftwareOnSailboats
 
What happens if you change it to
xml_node.Attributes(2).Value =
Now.ToString("yyyy-MM-ddTHH\:mm\:ss.fffffffzzz")
 
Well...I AM amazed...it works...now where is this little gem actually
documented so that mere mortals would have know about it? I read all about

\c...Where c is any character. Displays the character literally. To display
the backslash character, use "\\". etc, but that is not particularly
intuitive.

LOL

Thanks Alex!!
 
AH YES...THERE!

Thanks Alex...I had made the traditionally dreadful mistake of 'assuming'.
It made perfect sense to assume that ':' would insert a ":", and we all know
what good assumptions are!

Regards

Glyn




Alex Feinman said:
Well, I'm sure that by now you have seen the complete description of the
date/time format characters [1], but just to emphasize - contrary to the
expectations, the ':' formatter inserts time separator as defined by the
system locale. If you want the actual ':', preface it with \ to make it
literal.

[1]
http://msdn.microsoft.com/library/e...globalizationdatetimeformatinfoclasstopic.asp


--
Alex Feinman
---
Visit http://www.opennetcf.org
Glyn Meek said:
Well...I AM amazed...it works...now where is this little gem actually
documented so that mere mortals would have know about it? I read all
about

\c...Where c is any character. Displays the character literally. To
display the backslash character, use "\\". etc, but that is not
particularly intuitive.

LOL

Thanks Alex!!
 
Back
Top