|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
convert datetime to sortable formatI 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 Does the web service take a DateTime data type or a string?
-- Show quoteHTH, 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 > 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 > > 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 > 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 > > <pranesh.na***@gmail.com> wrote in message
news:1151469121.211522.120780@y41g2000cwy.googlegroups.com... What's the problem with this?> Yes, but without any luck... > > Sanjib Biswas wrote: >> Have you tried the following code? >> >> dy.ShortDatePattern = "yyyy-MM-ddT"; >> dy.ShortTimePattern = "HH:mm:ss"; -- Happy Hacking, Gaurav Vaish | http://www.mastergaurav.org http://www.edujini.in | http://webservices.edujini.in ------------------- |
|||||||||||||||||||||||