Date got offset by 1 day in webservice.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon429@gmail.com

    Date got offset by 1 day in webservice.

    Hi,

    I got a client application where it calls the webservices to save and
    retreive dates from an Oracle database. 1 problem I've encountered is
    that when a user select a certain date in the client application, when
    this date got to the webservice, it got offset by 1 day (plus/minus 1
    day depending on where is the user).

    Is there any easy solution where the date appears and saved as it is?
    i.e. user select 2nd July 2008, and the webservice gets and saves 2nd
    July 2008 without doing any region offset.

    Thanks,
    Simon
  • John Saunders

    #2
    Re: Date got offset by 1 day in webservice.

    <Simon429@gmail .comwrote in message
    news:09aecdc1-7f2f-4611-9229-533f940ebe7a@26 g2000hsk.google groups.com...
    Hi,
    >
    I got a client application where it calls the webservices to save and
    retreive dates from an Oracle database. 1 problem I've encountered is
    that when a user select a certain date in the client application, when
    this date got to the webservice, it got offset by 1 day (plus/minus 1
    day depending on where is the user).
    >
    Is there any easy solution where the date appears and saved as it is?
    i.e. user select 2nd July 2008, and the webservice gets and saves 2nd
    July 2008 without doing any region offset.
    Where are the users located? In the same time zone as the server or a
    different one?

    You should create yourself a simple example to reproduce this and narrow it
    down. For instance, it's possible the problem has nothing to do with Oracle,
    so your reproducer should not include Oracle or any other database. Just
    write a client that sends a known date and time to a service. Here's an
    example. Service:

    using System;
    using System.Globaliz ation;
    using System.Web.Serv ices;

    namespace TimezoneServer
    {
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Name space = "http://tempuri.org/")]
    [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
    [System.Componen tModel.ToolboxI tem(false)]
    public class Service1 : WebService
    {
    [WebMethod]
    public string DisplayTimeAndD ate(DateTime justDate, DateTime
    dateAndTime)
    {
    return String.Format(
    CultureInfo.Inv ariantCulture,
    "justDate={0}|d ateAndTime={1}" , justDate, dateAndTime);
    }
    }
    }

    Client:
    using System;

    using TimezoneClient. TimezoneService Proxy;

    namespace TimezoneClient
    {
    internal class Program
    {
    private static void Main()
    {
    using (TimezoneServic eProxy.Service1 svc = new Service1())
    {
    DateTime justDate = new DateTime(2008, 1, 2);
    DateTime dateAndTime = new DateTime(2008, 1, 2, 3, 4, 5);
    string response = svc.DisplayTime AndDate(justDat e,
    dateAndTime);
    Console.WriteLi ne(response);
    Console.Write(" Press ENTER to finish: ");
    Console.ReadLin e();
    }
    }
    }
    }

    Give that a try and see what the result is.
    --
    John Saunders | MVP - Connected System Developer

    Comment

    Working...