Android得到运行服务machine/server datetime



如何获取服务器日期时间。Android应用程序将访问webservice。我想知道如何获得服务器时间。这里我想通过。目前我得到了android时间.....

 // ksoap2 calling wcf
public SoapPrimitive soapPrimitiveData(String tablename) throws IOException,XmlPullParserException {
    SoapPrimitive responsesData = null;
    SoapObject requestData = new SoapObject(NAMESPACE, METHOD_TABLEDATA); // set
    //This place I need to get server time.Here I did as normal way
    Date date = new Date();
    DateFormat formatter = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
    String strDate = formatter.format(date);
    requestData.addProperty("strBusinessUnit", strBusinessUnit);
    requestData.addProperty("strExecutive", strExecutive);
    requestData.addProperty("strTableName", tablename);
    requestData.addProperty("strDate", strDate);
    requestData.addProperty("strTerritoryCode", strTerritoryCode);

    SoapSerializationEnvelope envelopes = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap//// envelope
    envelopes.dotNet = true;
    envelopes.setOutputSoapObject(requestData);
    AndroidHttpTransport httpTransport = new AndroidHttpTransport(APPURL);
    httpTransport.debug = true;
    try {
        httpTransport.call(SOAP_ACTION1, envelopes);
        responsesData = (SoapPrimitive) envelopes.getResponse();
    } catch (SocketException ex) {
        ex.printStackTrace();
    } catch (Exception e) {
       e.printStackTrace();
    }
    return responsesData;
}

请帮助我……

Thanks in advance....

要获取服务器时间,您应该与服务器有一个接口,您可以在其中请求时间。

例如,getTime.php可以是:

echo gmdate();

最新更新