简体   繁体   中英

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 :)

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 { }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM