Make WCF DateTime Compatible for Java client

I'am designing a WCF Service wich will be consumed by Java client by returning an array of object .

I design a small Java application to display the output object collection fields.

all fine except the DateTime wich is displayed as follow :

java.util.GregorianCalendar[time=1370969700000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+01:00",offset=3600000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2013,MONTH=5,WEEK_OF_YEAR=24,WEEK_OF_MONTH=2,DAY_OF_MONTH=11,DAY_OF_YEAR=162,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=55,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=0]

Could you at least guide me about some best pratice or attribute to add in my Service to prevent this issue ?

Is there any Java turn around ?

Thank you in advance


A Java Calendar objects gives you all the information you need to precisely definte the moment in time: the time itself (internally in millisecs since the epoch 01/01/1970), the timezone, ....

So there is nothing for you to do to change this behaviour, except that in your code you can obtain a "Date" object (also containing the time) from the calendar object you obtained using the getTime() method.

链接地址: http://www.djcxy.com/p/3092.html

上一篇: 日历获得年份返回错误的结果

下一篇: 使WCF DateTime兼容Java客户端