2012-02-14 112 views
0

上午使用在c#中实现的webservice为了上传一些值在sql服务器。我的代码是在java的android。 我的问题是,它只接受日期(yyyy-MM-dd),但我必须保存日期时间。 我usiging这个代码上传日期在web服务器在sql服务器

String currentDateTimeString = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); 
     request.addProperty("DateTimeStamp",currentDateTimeString); 

我尝试所有格式的时间,我可以找到,但它不接受任何。

相同的web服务正在使用从c#应用程序,并且工作得很好。它使用
private DateTime timeStamp;

它可能是相当于java的android。? 将SQL Server 2008 R2

回答

0

这个工作对我来说:

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
    Date date = new Date(); 
    values.put("time", dateFormat.format(date)); 
+0

偏偏仍无法正常工作。从Web服务的响应是空的,如果我只添加日期没有时间,它只是工作正常。任何其他想法可以帮助吗? – prokopis 2012-02-15 20:50:01