Home All Groups Group Topic Archive Search About

convert datetime to sortable format

Author
27 Jun 2006 6:38 AM
pranesh.nayak@gmail.com
Hello again,

I need to convert date to "yyyy-MM-ddTHH:mm:ss" format.

Below code does this, but it appends time twice in date variable.

DateTimeFormatInfo dy = new DateTimeFormatInfo();
dy.ShortDatePattern = "yyyy-MM-ddTHH:mm:ss";
dy.ShortTimePattern = "";
// next set dy to current culture
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat =
dy;
// now parse the date
DateTime date = DateTime.Parse("2006/12/12", new CultureInfo("en-US"),
DateTimeStyles.None);

This is appending time twice in date variable, (eg:
"2006/12/12T01:00:00 01:00:00")

I need to pass this variable (as DateTime type) to Java webservice.

any suggestions on how to get the date in reqd format?

Thanks

Author
27 Jun 2006 10:55 AM
Kevin Spencer
Does the web service take a DateTime data type or a string?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.


<pranesh.na***@gmail.com> wrote in message
Show quote
news:1151390323.594585.161990@y41g2000cwy.googlegroups.com...
> Hello again,
>
> I need to convert date to "yyyy-MM-ddTHH:mm:ss" format.
>
> Below code does this, but it appends time twice in date variable.
>
> DateTimeFormatInfo dy = new DateTimeFormatInfo();
> dy.ShortDatePattern = "yyyy-MM-ddTHH:mm:ss";
> dy.ShortTimePattern = "";
> // next set dy to current culture
> System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat =
> dy;
> // now parse the date
> DateTime date = DateTime.Parse("2006/12/12", new CultureInfo("en-US"),
> DateTimeStyles.None);
>
> This is appending time twice in date variable, (eg:
> "2006/12/12T01:00:00 01:00:00")
>
> I need to pass this variable (as DateTime type) to Java webservice.
>
> any suggestions on how to get the date in reqd format?
>
> Thanks
>
Author
28 Jun 2006 4:31 AM
pranesh.nayak@gmail.com
Webservice takes DateTime data type as parameter..

after debugging more I found that .Net runtime is not recognising
xs:DateTime format.

When I try to read data from that webservice got an error sayign:
"String was not recognized as a valid DateTime".

So we can conclude that xs:DateTime format is incompatible with .Net.
Please refer this article :
http://www.mcse.ms/archive105-2004-7-899102.html
about similar problem.

since its a 3rd party webservice i can't touch it. The other solution
given in this article (using [XMLIgnore]) did not work for me.

Please advise if you have any idea abt this.

Thanks..
Raghu





Kevin Spencer wrote:
Show quote
> Does the web service take a DateTime data type or a string?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Chicken Salad Alchemist
>
> Big thicks are made up of lots of little thins.
>
>
> <pranesh.na***@gmail.com> wrote in message
> news:1151390323.594585.161990@y41g2000cwy.googlegroups.com...
> > Hello again,
> >
> > I need to convert date to "yyyy-MM-ddTHH:mm:ss" format.
> >
> > Below code does this, but it appends time twice in date variable.
> >
> > DateTimeFormatInfo dy = new DateTimeFormatInfo();
> > dy.ShortDatePattern = "yyyy-MM-ddTHH:mm:ss";
> > dy.ShortTimePattern = "";
> > // next set dy to current culture
> > System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat =
> > dy;
> > // now parse the date
> > DateTime date = DateTime.Parse("2006/12/12", new CultureInfo("en-US"),
> > DateTimeStyles.None);
> >
> > This is appending time twice in date variable, (eg:
> > "2006/12/12T01:00:00 01:00:00")
> >
> > I need to pass this variable (as DateTime type) to Java webservice.
> >
> > any suggestions on how to get the date in reqd format?
> >
> > Thanks
> >
Author
27 Jun 2006 12:23 PM
Sanjib Biswas
Have you tried the following code?

dy.ShortDatePattern = "yyyy-MM-ddT";
dy.ShortTimePattern = "HH:mm:ss";

<pranesh.na***@gmail.com> wrote in message
Show quote
news:1151390323.594585.161990@y41g2000cwy.googlegroups.com...
> Hello again,
>
> I need to convert date to "yyyy-MM-ddTHH:mm:ss" format.
>
> Below code does this, but it appends time twice in date variable.
>
> DateTimeFormatInfo dy = new DateTimeFormatInfo();
> dy.ShortDatePattern = "yyyy-MM-ddTHH:mm:ss";
> dy.ShortTimePattern = "";
> // next set dy to current culture
> System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat =
> dy;
> // now parse the date
> DateTime date = DateTime.Parse("2006/12/12", new CultureInfo("en-US"),
> DateTimeStyles.None);
>
> This is appending time twice in date variable, (eg:
> "2006/12/12T01:00:00 01:00:00")
>
> I need to pass this variable (as DateTime type) to Java webservice.
>
> any suggestions on how to get the date in reqd format?
>
> Thanks
>
Author
28 Jun 2006 4:32 AM
pranesh.nayak@gmail.com
Yes, but without any luck...

Sanjib Biswas wrote:
Show quote
> Have you tried the following code?
>
> dy.ShortDatePattern = "yyyy-MM-ddT";
> dy.ShortTimePattern = "HH:mm:ss";
>
> <pranesh.na***@gmail.com> wrote in message
> news:1151390323.594585.161990@y41g2000cwy.googlegroups.com...
> > Hello again,
> >
> > I need to convert date to "yyyy-MM-ddTHH:mm:ss" format.
> >
> > Below code does this, but it appends time twice in date variable.
> >
> > DateTimeFormatInfo dy = new DateTimeFormatInfo();
> > dy.ShortDatePattern = "yyyy-MM-ddTHH:mm:ss";
> > dy.ShortTimePattern = "";
> > // next set dy to current culture
> > System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat =
> > dy;
> > // now parse the date
> > DateTime date = DateTime.Parse("2006/12/12", new CultureInfo("en-US"),
> > DateTimeStyles.None);
> >
> > This is appending time twice in date variable, (eg:
> > "2006/12/12T01:00:00 01:00:00")
> >
> > I need to pass this variable (as DateTime type) to Java webservice.
> >
> > any suggestions on how to get the date in reqd format?
> >
> > Thanks
> >
Author
27 Aug 2006 6:53 PM
Gaurav Vaish (www.EduJini.IN)
<pranesh.na***@gmail.com> wrote in message
news:1151469121.211522.120780@y41g2000cwy.googlegroups.com...
> Yes, but without any luck...
>
> Sanjib Biswas wrote:
>> Have you tried the following code?
>>
>> dy.ShortDatePattern = "yyyy-MM-ddT";
>> dy.ShortTimePattern = "HH:mm:ss";

What's the problem with this?


--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------

AddThis Social Bookmark Button