Search code examples
c#javawcfdatetimeksoap2

Ksoap2 : Calling DateTime datatype on .NET Web Service


I have a WCF Web Service. This service I have tested successfully on .NET Platform.

I use Ksoap 2 to generate Java classes file to consume this service. When use KSoap2, DateTime Datatype becomes String (Due to Java doesn't have DateTime datatype comparable with DateTime in .NET)

So, at getter attribute for object, I don't know how to set value :

for example :

student.birth = "12/12/2013"
student.birth = "2013/12/12"

I have tested on some case, but maybe because the format is not true, I get this exception :

This Value cannot be set to NULL 

I don't know which value. But I guess birth field above.

So. My question is : How to use DateTime data type in KSoap ? Which structure should I put in datetime string ?

Thanks :)


Solution

  • My only guess would be to use datetime.format strings

    http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx

    public class DateExample
    {
        private DateTime _dt;
        public string dt
        {
            get
            {
                return _dt.ToString("hh:mm:ss tt",
                    System.Globalization.CultureInfo.InvariantCulture);
                // Displays 06:09:01 PM 
            }
            private set { }
        }
    }