datetime format in xml

Discussion in 'ASP .Net Web Services' started by Guest, Nov 8, 2005.

  1. Guest

    Guest Guest

    Hi all, I am consuming a web service on .net client side. I generated the
    proxy class and it has a custom object with a few datetime properties. The
    problem is when I populate some of those properties, the underlying xml
    serializer formats the property as outlined below

    2005-11-07T18:34:36.6990563-06:00

    The problem is the WS needs it in the following format:-

    2005-11-04T08:30:39

    Any ideas on how I can control this?

    TIA!
    Guest, Nov 8, 2005
    #1
    1. Advertising

  2. Hi Param,

    Welcome to MSDN newsgroup.
    From your description, you're cosuming a certain webservice which will pass
    DateTime object in your .NET client app. And you found that the default
    serlized datetime output is not quite suit the webservice's actual
    requirement, yes?

    As for this quesiton, I think it is due to the current .net framework (1.0,
    1.1)'s DateTime class's limitation. The current DateTime class is always
    persisted as local time format (with TimeZone offset...), also the

    2005-11-07T18:34:36.6990563-06:00

    output you got is the default xml serlization output. Since we can not
    control the underlying xmlserlization of the DateTime class( build-in basic
    type), I'd suggest you consider modifying the .NET client proxy code,
    change that class property which uesd to be DateTime type to a string type.
    Then, we can use the DateTime class's ToString method to perform datetime
    formatting which can output many different formats we want, here is the
    related msdn reference on DateTime formatting:

    #Standard DateTime Format Strings Output Examples
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstandarddatetimefo
    rmatstringsoutputexample.asp?frame=true

    Also, another msdn article discussing on the best practice using DateTime
    in .net 1.x application:

    #Coding Best Practices Using DateTime in the .NET Framework
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    ml/datetimecode.asp

    Hope helps. Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)


    --------------------
    | From: <>
    | Subject: datetime format in xml
    | Date: Tue, 8 Nov 2005 09:33:07 -0600
    | Lines: 16
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webservices:8304
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    |
    | Hi all, I am consuming a web service on .net client side. I generated the
    | proxy class and it has a custom object with a few datetime properties.
    The
    | problem is when I populate some of those properties, the underlying xml
    | serializer formats the property as outlined below
    |
    | 2005-11-07T18:34:36.6990563-06:00
    |
    | The problem is the WS needs it in the following format:-
    |
    | 2005-11-04T08:30:39
    |
    | Any ideas on how I can control this?
    |
    | TIA!
    |
    |
    |
    Steven Cheng[MSFT], Nov 9, 2005
    #2
    1. Advertising

  3. Guest

    Guest Guest

    Does this behavior change in Net 2.0? If so, how?


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Param,
    >
    > Welcome to MSDN newsgroup.
    > From your description, you're cosuming a certain webservice which will
    > pass
    > DateTime object in your .NET client app. And you found that the default
    > serlized datetime output is not quite suit the webservice's actual
    > requirement, yes?
    >
    > As for this quesiton, I think it is due to the current .net framework
    > (1.0,
    > 1.1)'s DateTime class's limitation. The current DateTime class is always
    > persisted as local time format (with TimeZone offset...), also the
    >
    > 2005-11-07T18:34:36.6990563-06:00
    >
    > output you got is the default xml serlization output. Since we can not
    > control the underlying xmlserlization of the DateTime class( build-in
    > basic
    > type), I'd suggest you consider modifying the .NET client proxy code,
    > change that class property which uesd to be DateTime type to a string
    > type.
    > Then, we can use the DateTime class's ToString method to perform datetime
    > formatting which can output many different formats we want, here is the
    > related msdn reference on DateTime formatting:
    >
    > #Standard DateTime Format Strings Output Examples
    > http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstandarddatetimefo
    > rmatstringsoutputexample.asp?frame=true
    >
    > Also, another msdn article discussing on the best practice using DateTime
    > in .net 1.x application:
    >
    > #Coding Best Practices Using DateTime in the .NET Framework
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    > ml/datetimecode.asp
    >
    > Hope helps. Thanks,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    > --------------------
    > | From: <>
    > | Subject: datetime format in xml
    > | Date: Tue, 8 Nov 2005 09:33:07 -0600
    > | Lines: 16
    > | X-Priority: 3
    > | X-MSMail-Priority: Normal
    > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    > | X-RFC2646: Format=Flowed; Original
    > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    > | Message-ID: <>
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    > | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    > | Xref: TK2MSFTNGXA01.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.webservices:8304
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    > |
    > | Hi all, I am consuming a web service on .net client side. I generated
    > the
    > | proxy class and it has a custom object with a few datetime properties.
    > The
    > | problem is when I populate some of those properties, the underlying xml
    > | serializer formats the property as outlined below
    > |
    > | 2005-11-07T18:34:36.6990563-06:00
    > |
    > | The problem is the WS needs it in the following format:-
    > |
    > | 2005-11-04T08:30:39
    > |
    > | Any ideas on how I can control this?
    > |
    > | TIA!
    > |
    > |
    > |
    >
    Guest, Nov 9, 2005
    #3
  4. Thanks for your respone Param,

    As for .NET 2.0, of course the DateTime type has greatly enchanged. The
    .NET 2.0 DateTime class support a DateTimeKind property which help specify
    whether the datetime object is representing a local time, UTC time or
    unspecified....

    So for local and utc time, the default xmlserliazation output will like
    below:


    local now:

    <dateTime>2005-11-10T13:50:52.5979344-08:00</dateTime>

    utc now:

    <dateTime>2005-11-10T21:50:52.5979344Z</dateTime>


    so we can see for UTC time it no longer append the unused TimeZone offset.
    However, since the milliseconds is necessary for precise purpose, it is
    still appended. So for you scenario, we should use the DateTime Formatting
    flag to manually do the formatting so as to get the output we want.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    --------------------
    | From: <>
    | References: <>
    <>
    | Subject: Re: datetime format in xml
    | Date: Wed, 9 Nov 2005 08:51:51 -0600
    | Lines: 92
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | Message-ID: <#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webservices:30825
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    |
    | Does this behavior change in Net 2.0? If so, how?
    |
    |
    | "Steven Cheng[MSFT]" <> wrote in message
    | news:...
    | > Hi Param,
    | >
    | > Welcome to MSDN newsgroup.
    | > From your description, you're cosuming a certain webservice which will
    | > pass
    | > DateTime object in your .NET client app. And you found that the default
    | > serlized datetime output is not quite suit the webservice's actual
    | > requirement, yes?
    | >
    | > As for this quesiton, I think it is due to the current .net framework
    | > (1.0,
    | > 1.1)'s DateTime class's limitation. The current DateTime class is always
    | > persisted as local time format (with TimeZone offset...), also the
    | >
    | > 2005-11-07T18:34:36.6990563-06:00
    | >
    | > output you got is the default xml serlization output. Since we can not
    | > control the underlying xmlserlization of the DateTime class( build-in
    | > basic
    | > type), I'd suggest you consider modifying the .NET client proxy code,
    | > change that class property which uesd to be DateTime type to a string
    | > type.
    | > Then, we can use the DateTime class's ToString method to perform
    datetime
    | > formatting which can output many different formats we want, here is the
    | > related msdn reference on DateTime formatting:
    | >
    | > #Standard DateTime Format Strings Output Examples
    | >
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstandarddatetimefo
    | > rmatstringsoutputexample.asp?frame=true
    | >
    | > Also, another msdn article discussing on the best practice using
    DateTime
    | > in .net 1.x application:
    | >
    | > #Coding Best Practices Using DateTime in the .NET Framework
    | >
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    | > ml/datetimecode.asp
    | >
    | > Hope helps. Thanks,
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! www.microsoft.com/security
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | >
    | >
    | > --------------------
    | > | From: <>
    | > | Subject: datetime format in xml
    | > | Date: Tue, 8 Nov 2005 09:33:07 -0600
    | > | Lines: 16
    | > | X-Priority: 3
    | > | X-MSMail-Priority: Normal
    | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | > | X-RFC2646: Format=Flowed; Original
    | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | > | Message-ID: <>
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | > | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    | > | Xref: TK2MSFTNGXA01.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.webservices:8304
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    | > |
    | > | Hi all, I am consuming a web service on .net client side. I generated
    | > the
    | > | proxy class and it has a custom object with a few datetime properties.
    | > The
    | > | problem is when I populate some of those properties, the underlying
    xml
    | > | serializer formats the property as outlined below
    | > |
    | > | 2005-11-07T18:34:36.6990563-06:00
    | > |
    | > | The problem is the WS needs it in the following format:-
    | > |
    | > | 2005-11-04T08:30:39
    | > |
    | > | Any ideas on how I can control this?
    | > |
    | > | TIA!
    | > |
    | > |
    | > |
    | >
    |
    |
    |
    Steven Cheng[MSFT], Nov 10, 2005
    #4
  5. Hi Param,

    Does my further reply helps a little? If there're still anything else we
    can help, please feel free to post here.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | X-Tomcat-ID: 130864800
    | References: <>
    <>
    <#>
    | MIME-Version: 1.0
    | Content-Type: text/plain
    | Content-Transfer-Encoding: 7bit
    | From: (Steven Cheng[MSFT])
    | Organization: Microsoft
    | Date: Thu, 10 Nov 2005 05:56:31 GMT
    | Subject: Re: datetime format in xml
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | Lines: 133
    | Path: TK2MSFTNGXA02.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webservices:30835
    | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
    |
    | Thanks for your respone Param,
    |
    | As for .NET 2.0, of course the DateTime type has greatly enchanged. The
    | .NET 2.0 DateTime class support a DateTimeKind property which help
    specify
    | whether the datetime object is representing a local time, UTC time or
    | unspecified....
    |
    | So for local and utc time, the default xmlserliazation output will like
    | below:
    |
    |
    | local now:
    |
    | <dateTime>2005-11-10T13:50:52.5979344-08:00</dateTime>
    |
    | utc now:
    |
    | <dateTime>2005-11-10T21:50:52.5979344Z</dateTime>
    |
    |
    | so we can see for UTC time it no longer append the unused TimeZone
    offset.
    | However, since the milliseconds is necessary for precise purpose, it is
    | still appended. So for you scenario, we should use the DateTime
    Formatting
    | flag to manually do the formatting so as to get the output we want.
    |
    | Thanks,
    |
    | Steven Cheng
    | Microsoft Online Support
    |
    | Get Secure! www.microsoft.com/security
    | (This posting is provided "AS IS", with no warranties, and confers no
    | rights.)
    |
    | --------------------
    | | From: <>
    | | References: <>
    | <>
    | | Subject: Re: datetime format in xml
    | | Date: Wed, 9 Nov 2005 08:51:51 -0600
    | | Lines: 92
    | | X-Priority: 3
    | | X-MSMail-Priority: Normal
    | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | | X-RFC2646: Format=Flowed; Original
    | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | | Message-ID: <#>
    | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | | NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
    | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | | Xref: TK2MSFTNGXA02.phx.gbl
    | microsoft.public.dotnet.framework.aspnet.webservices:30825
    | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    | |
    | | Does this behavior change in Net 2.0? If so, how?
    | |
    | |
    | | "Steven Cheng[MSFT]" <> wrote in message
    | | news:...
    | | > Hi Param,
    | | >
    | | > Welcome to MSDN newsgroup.
    | | > From your description, you're cosuming a certain webservice which
    will
    | | > pass
    | | > DateTime object in your .NET client app. And you found that the
    default
    | | > serlized datetime output is not quite suit the webservice's actual
    | | > requirement, yes?
    | | >
    | | > As for this quesiton, I think it is due to the current .net framework
    | | > (1.0,
    | | > 1.1)'s DateTime class's limitation. The current DateTime class is
    always
    | | > persisted as local time format (with TimeZone offset...), also the
    | | >
    | | > 2005-11-07T18:34:36.6990563-06:00
    | | >
    | | > output you got is the default xml serlization output. Since we can not
    | | > control the underlying xmlserlization of the DateTime class( build-in
    | | > basic
    | | > type), I'd suggest you consider modifying the .NET client proxy code,
    | | > change that class property which uesd to be DateTime type to a string
    | | > type.
    | | > Then, we can use the DateTime class's ToString method to perform
    | datetime
    | | > formatting which can output many different formats we want, here is
    the
    | | > related msdn reference on DateTime formatting:
    | | >
    | | > #Standard DateTime Format Strings Output Examples
    | | >
    |
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstandarddatetimefo
    | | > rmatstringsoutputexample.asp?frame=true
    | | >
    | | > Also, another msdn article discussing on the best practice using
    | DateTime
    | | > in .net 1.x application:
    | | >
    | | > #Coding Best Practices Using DateTime in the .NET Framework
    | | >
    |
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    | | > ml/datetimecode.asp
    | | >
    | | > Hope helps. Thanks,
    | | >
    | | > Steven Cheng
    | | > Microsoft Online Support
    | | >
    | | > Get Secure! www.microsoft.com/security
    | | > (This posting is provided "AS IS", with no warranties, and confers no
    | | > rights.)
    | | >
    | | >
    | | > --------------------
    | | > | From: <>
    | | > | Subject: datetime format in xml
    | | > | Date: Tue, 8 Nov 2005 09:33:07 -0600
    | | > | Lines: 16
    | | > | X-Priority: 3
    | | > | X-MSMail-Priority: Normal
    | | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | | > | X-RFC2646: Format=Flowed; Original
    | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | | > | Message-ID: <>
    | | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | | > | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    | | > | Path:
    TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    | | > | Xref: TK2MSFTNGXA01.phx.gbl
    | | > microsoft.public.dotnet.framework.aspnet.webservices:8304
    | | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    | | > |
    | | > | Hi all, I am consuming a web service on .net client side. I
    generated
    | | > the
    | | > | proxy class and it has a custom object with a few datetime
    properties.
    | | > The
    | | > | problem is when I populate some of those properties, the underlying
    | xml
    | | > | serializer formats the property as outlined below
    | | > |
    | | > | 2005-11-07T18:34:36.6990563-06:00
    | | > |
    | | > | The problem is the WS needs it in the following format:-
    | | > |
    | | > | 2005-11-04T08:30:39
    | | > |
    | | > | Any ideas on how I can control this?
    | | > |
    | | > | TIA!
    | | > |
    | | > |
    | | > |
    | | >
    | |
    | |
    | |
    |
    |
    Steven Cheng[MSFT], Nov 14, 2005
    #5
  6. Guest

    Guest Guest

    It worked. Thanks!

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Param,
    >
    > Does my further reply helps a little? If there're still anything else we
    > can help, please feel free to post here.
    >
    > Thanks,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    > --------------------
    > | X-Tomcat-ID: 130864800
    > | References: <>
    > <>
    > <#>
    > | MIME-Version: 1.0
    > | Content-Type: text/plain
    > | Content-Transfer-Encoding: 7bit
    > | From: (Steven Cheng[MSFT])
    > | Organization: Microsoft
    > | Date: Thu, 10 Nov 2005 05:56:31 GMT
    > | Subject: Re: datetime format in xml
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    > | Message-ID: <>
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    > | Lines: 133
    > | Path: TK2MSFTNGXA02.phx.gbl
    > | Xref: TK2MSFTNGXA02.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.webservices:30835
    > | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
    > |
    > | Thanks for your respone Param,
    > |
    > | As for .NET 2.0, of course the DateTime type has greatly enchanged. The
    > | .NET 2.0 DateTime class support a DateTimeKind property which help
    > specify
    > | whether the datetime object is representing a local time, UTC time or
    > | unspecified....
    > |
    > | So for local and utc time, the default xmlserliazation output will like
    > | below:
    > |
    > |
    > | local now:
    > |
    > | <dateTime>2005-11-10T13:50:52.5979344-08:00</dateTime>
    > |
    > | utc now:
    > |
    > | <dateTime>2005-11-10T21:50:52.5979344Z</dateTime>
    > |
    > |
    > | so we can see for UTC time it no longer append the unused TimeZone
    > offset.
    > | However, since the milliseconds is necessary for precise purpose, it is
    > | still appended. So for you scenario, we should use the DateTime
    > Formatting
    > | flag to manually do the formatting so as to get the output we want.
    > |
    > | Thanks,
    > |
    > | Steven Cheng
    > | Microsoft Online Support
    > |
    > | Get Secure! www.microsoft.com/security
    > | (This posting is provided "AS IS", with no warranties, and confers no
    > | rights.)
    > |
    > | --------------------
    > | | From: <>
    > | | References: <>
    > | <>
    > | | Subject: Re: datetime format in xml
    > | | Date: Wed, 9 Nov 2005 08:51:51 -0600
    > | | Lines: 92
    > | | X-Priority: 3
    > | | X-MSMail-Priority: Normal
    > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    > | | X-RFC2646: Format=Flowed; Original
    > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    > | | Message-ID: <#>
    > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    > | | NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
    > | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    > | | Xref: TK2MSFTNGXA02.phx.gbl
    > | microsoft.public.dotnet.framework.aspnet.webservices:30825
    > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    > | |
    > | | Does this behavior change in Net 2.0? If so, how?
    > | |
    > | |
    > | | "Steven Cheng[MSFT]" <> wrote in message
    > | | news:...
    > | | > Hi Param,
    > | | >
    > | | > Welcome to MSDN newsgroup.
    > | | > From your description, you're cosuming a certain webservice which
    > will
    > | | > pass
    > | | > DateTime object in your .NET client app. And you found that the
    > default
    > | | > serlized datetime output is not quite suit the webservice's actual
    > | | > requirement, yes?
    > | | >
    > | | > As for this quesiton, I think it is due to the current .net
    > framework
    > | | > (1.0,
    > | | > 1.1)'s DateTime class's limitation. The current DateTime class is
    > always
    > | | > persisted as local time format (with TimeZone offset...), also the
    > | | >
    > | | > 2005-11-07T18:34:36.6990563-06:00
    > | | >
    > | | > output you got is the default xml serlization output. Since we can
    > not
    > | | > control the underlying xmlserlization of the DateTime class(
    > build-in
    > | | > basic
    > | | > type), I'd suggest you consider modifying the .NET client proxy
    > code,
    > | | > change that class property which uesd to be DateTime type to a
    > string
    > | | > type.
    > | | > Then, we can use the DateTime class's ToString method to perform
    > | datetime
    > | | > formatting which can output many different formats we want, here is
    > the
    > | | > related msdn reference on DateTime formatting:
    > | | >
    > | | > #Standard DateTime Format Strings Output Examples
    > | | >
    > |
    > http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstandarddatetimefo
    > | | > rmatstringsoutputexample.asp?frame=true
    > | | >
    > | | > Also, another msdn article discussing on the best practice using
    > | DateTime
    > | | > in .net 1.x application:
    > | | >
    > | | > #Coding Best Practices Using DateTime in the .NET Framework
    > | | >
    > |
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    > | | > ml/datetimecode.asp
    > | | >
    > | | > Hope helps. Thanks,
    > | | >
    > | | > Steven Cheng
    > | | > Microsoft Online Support
    > | | >
    > | | > Get Secure! www.microsoft.com/security
    > | | > (This posting is provided "AS IS", with no warranties, and confers
    > no
    > | | > rights.)
    > | | >
    > | | >
    > | | > --------------------
    > | | > | From: <>
    > | | > | Subject: datetime format in xml
    > | | > | Date: Tue, 8 Nov 2005 09:33:07 -0600
    > | | > | Lines: 16
    > | | > | X-Priority: 3
    > | | > | X-MSMail-Priority: Normal
    > | | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    > | | > | X-RFC2646: Format=Flowed; Original
    > | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    > | | > | Message-ID: <>
    > | | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    > | | > | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    > | | > | Path:
    > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    > | | > | Xref: TK2MSFTNGXA01.phx.gbl
    > | | > microsoft.public.dotnet.framework.aspnet.webservices:8304
    > | | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    > | | > |
    > | | > | Hi all, I am consuming a web service on .net client side. I
    > generated
    > | | > the
    > | | > | proxy class and it has a custom object with a few datetime
    > properties.
    > | | > The
    > | | > | problem is when I populate some of those properties, the
    > underlying
    > | xml
    > | | > | serializer formats the property as outlined below
    > | | > |
    > | | > | 2005-11-07T18:34:36.6990563-06:00
    > | | > |
    > | | > | The problem is the WS needs it in the following format:-
    > | | > |
    > | | > | 2005-11-04T08:30:39
    > | | > |
    > | | > | Any ideas on how I can control this?
    > | | > |
    > | | > | TIA!
    > | | > |
    > | | > |
    > | | > |
    > | | >
    > | |
    > | |
    > | |
    > |
    > |
    >
    Guest, Nov 15, 2005
    #6
  7. You're welcome Param,

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | From: <>
    | References: <>
    <>
    <#>
    <>
    <>
    | Subject: Re: datetime format in xml
    | Date: Mon, 14 Nov 2005 22:20:35 -0600
    | Lines: 214
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.webservices:30884
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    |
    | It worked. Thanks!
    |
    | "Steven Cheng[MSFT]" <> wrote in message
    | news:...
    | > Hi Param,
    | >
    | > Does my further reply helps a little? If there're still anything else we
    | > can help, please feel free to post here.
    | >
    | > Thanks,
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! www.microsoft.com/security
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | > --------------------
    | > | X-Tomcat-ID: 130864800
    | > | References: <>
    | > <>
    | > <#>
    | > | MIME-Version: 1.0
    | > | Content-Type: text/plain
    | > | Content-Transfer-Encoding: 7bit
    | > | From: (Steven Cheng[MSFT])
    | > | Organization: Microsoft
    | > | Date: Thu, 10 Nov 2005 05:56:31 GMT
    | > | Subject: Re: datetime format in xml
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    | > | Message-ID: <>
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | > | Lines: 133
    | > | Path: TK2MSFTNGXA02.phx.gbl
    | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.webservices:30835
    | > | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
    | > |
    | > | Thanks for your respone Param,
    | > |
    | > | As for .NET 2.0, of course the DateTime type has greatly enchanged.
    The
    | > | .NET 2.0 DateTime class support a DateTimeKind property which help
    | > specify
    | > | whether the datetime object is representing a local time, UTC time or
    | > | unspecified....
    | > |
    | > | So for local and utc time, the default xmlserliazation output will
    like
    | > | below:
    | > |
    | > |
    | > | local now:
    | > |
    | > | <dateTime>2005-11-10T13:50:52.5979344-08:00</dateTime>
    | > |
    | > | utc now:
    | > |
    | > | <dateTime>2005-11-10T21:50:52.5979344Z</dateTime>
    | > |
    | > |
    | > | so we can see for UTC time it no longer append the unused TimeZone
    | > offset.
    | > | However, since the milliseconds is necessary for precise purpose, it
    is
    | > | still appended. So for you scenario, we should use the DateTime
    | > Formatting
    | > | flag to manually do the formatting so as to get the output we want.
    | > |
    | > | Thanks,
    | > |
    | > | Steven Cheng
    | > | Microsoft Online Support
    | > |
    | > | Get Secure! www.microsoft.com/security
    | > | (This posting is provided "AS IS", with no warranties, and confers no
    | > | rights.)
    | > |
    | > | --------------------
    | > | | From: <>
    | > | | References: <>
    | > | <>
    | > | | Subject: Re: datetime format in xml
    | > | | Date: Wed, 9 Nov 2005 08:51:51 -0600
    | > | | Lines: 92
    | > | | X-Priority: 3
    | > | | X-MSMail-Priority: Normal
    | > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | > | | X-RFC2646: Format=Flowed; Original
    | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | > | | Message-ID: <#>
    | > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | > | | NNTP-Posting-Host: corp2.lazardgroup.com 70.182.148.88
    | > | | Path:
    TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | > | | Xref: TK2MSFTNGXA02.phx.gbl
    | > | microsoft.public.dotnet.framework.aspnet.webservices:30825
    | > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    | > | |
    | > | | Does this behavior change in Net 2.0? If so, how?
    | > | |
    | > | |
    | > | | "Steven Cheng[MSFT]" <> wrote in message
    | > | | news:...
    | > | | > Hi Param,
    | > | | >
    | > | | > Welcome to MSDN newsgroup.
    | > | | > From your description, you're cosuming a certain webservice which
    | > will
    | > | | > pass
    | > | | > DateTime object in your .NET client app. And you found that the
    | > default
    | > | | > serlized datetime output is not quite suit the webservice's actual
    | > | | > requirement, yes?
    | > | | >
    | > | | > As for this quesiton, I think it is due to the current .net
    | > framework
    | > | | > (1.0,
    | > | | > 1.1)'s DateTime class's limitation. The current DateTime class is
    | > always
    | > | | > persisted as local time format (with TimeZone offset...), also the
    | > | | >
    | > | | > 2005-11-07T18:34:36.6990563-06:00
    | > | | >
    | > | | > output you got is the default xml serlization output. Since we
    can
    | > not
    | > | | > control the underlying xmlserlization of the DateTime class(
    | > build-in
    | > | | > basic
    | > | | > type), I'd suggest you consider modifying the .NET client proxy
    | > code,
    | > | | > change that class property which uesd to be DateTime type to a
    | > string
    | > | | > type.
    | > | | > Then, we can use the DateTime class's ToString method to perform
    | > | datetime
    | > | | > formatting which can output many different formats we want, here
    is
    | > the
    | > | | > related msdn reference on DateTime formatting:
    | > | | >
    | > | | > #Standard DateTime Format Strings Output Examples
    | > | | >
    | > |
    | >
    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstandarddatetimefo
    | > | | > rmatstringsoutputexample.asp?frame=true
    | > | | >
    | > | | > Also, another msdn article discussing on the best practice using
    | > | DateTime
    | > | | > in .net 1.x application:
    | > | | >
    | > | | > #Coding Best Practices Using DateTime in the .NET Framework
    | > | | >
    | > |
    | >
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    | > | | > ml/datetimecode.asp
    | > | | >
    | > | | > Hope helps. Thanks,
    | > | | >
    | > | | > Steven Cheng
    | > | | > Microsoft Online Support
    | > | | >
    | > | | > Get Secure! www.microsoft.com/security
    | > | | > (This posting is provided "AS IS", with no warranties, and
    confers
    | > no
    | > | | > rights.)
    | > | | >
    | > | | >
    | > | | > --------------------
    | > | | > | From: <>
    | > | | > | Subject: datetime format in xml
    | > | | > | Date: Tue, 8 Nov 2005 09:33:07 -0600
    | > | | > | Lines: 16
    | > | | > | X-Priority: 3
    | > | | > | X-MSMail-Priority: Normal
    | > | | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | > | | > | X-RFC2646: Format=Flowed; Original
    | > | | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | > | | > | Message-ID: <>
    | > | | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    | > | | > | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
    | > | | > | Path:
    | > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    | > | | > | Xref: TK2MSFTNGXA01.phx.gbl
    | > | | > microsoft.public.dotnet.framework.aspnet.webservices:8304
    | > | | > | X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet.webservices
    | > | | > |
    | > | | > | Hi all, I am consuming a web service on .net client side. I
    | > generated
    | > | | > the
    | > | | > | proxy class and it has a custom object with a few datetime
    | > properties.
    | > | | > The
    | > | | > | problem is when I populate some of those properties, the
    | > underlying
    | > | xml
    | > | | > | serializer formats the property as outlined below
    | > | | > |
    | > | | > | 2005-11-07T18:34:36.6990563-06:00
    | > | | > |
    | > | | > | The problem is the WS needs it in the following format:-
    | > | | > |
    | > | | > | 2005-11-04T08:30:39
    | > | | > |
    | > | | > | Any ideas on how I can control this?
    | > | | > |
    | > | | > | TIA!
    | > | | > |
    | > | | > |
    | > | | > |
    | > | | >
    | > | |
    | > | |
    | > | |
    | > |
    | > |
    | >
    |
    |
    |
    Steven Cheng[MSFT], Nov 15, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    686
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    519
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    373
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    328
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    743
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page