Gustav Brock
gustav at cactus.dk
Sat Jun 11 17:30:44 CDT 2011
Hi Shamil
Ha ha, "got a Glueck", that explains!
/gustav
>>> shamil at smsconsulting.spb.ru 11-06-2011 16:36 >>>
Hi Gustav --
That was "miPtySing".
I meant .NET Framework's built-in System.TimeSpan struct not TimeStamp
(which doesn't exist).
I typed my code snippet from memory and my "brainputer"'s memory obviously
"got a Glueck" after a heavy duty working day of a large batch of VS2008
projects conversion to VS2010.
Correct sample code snippet should have been something like the following:
// Define TimeSpan value equal to
// 10 hours 11 minutes and 12 seconds
TimeSpan ts = new TimeSpan(10, 11, 12);
// correct TimeSpan value formatting
string s = string.Format("Correct = {0:hh\\:mm\\:ss}", ts);
System.Console.WriteLine(s);
// incorrect TimeSpan value formatting
try
{
s = string.Format("Incorrect = {0:hh:mm:ss}", ts);
System.Console.WriteLine(s);
}
catch (Exception ex)
{
System.Console.WriteLine("Error: {0}", ex.Message);
}
Thank you.
--
Shamil
P.S. Sorry for delay with my reply - I've got a short vacation immediately
after I have posted to Access-D my original posting...
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: 6 ???? 2011 ?. 14:08
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] FYI: TimeStamp formatting issue for VS2010/.NET 4.0
Hi Shamil
By the way, where does "TimeSpan" come from? Is it native to C# or custom by
you?
/gustav
>>> shamil at smsconsulting.spb.ru 05-06-2011 22:12 >>>
Hi All --
FYI: I have got used to format TimeStamp values this simple way (for
TimeStamp values less than a day):
TimeStamp ts = new TimeStamp(10,11,12);
string s = string.Format("{0:hh:mm:ss}", ts); System.Console.WriteLine(s);
and it worked well for VS2008/.NET 3.5 but when my project was converted to
VS2010SP1/.NET 4.0 I have got runtime error...
Proper TimeStamp formatting for my case should be {0:hh\\:mm\\:ss} :
TimeStamp ts = new TimeStamp(10,11,12);
string s = string.Format("{0:hh\\:mm\\:ss}", ts);
System.Console.WriteLine(s);
Source: http://msdn.microsoft.com/en-us/library/ee372287.aspx
Thank you.
--
Shamil