| 7908 |
manish.sha |
1 |
package com.fedex.soapsamples.util;
|
|
|
2 |
|
|
|
3 |
import org.apache.axis.encoding.SerializationContext;
|
|
|
4 |
import org.apache.axis.encoding.ser.CalendarSerializer;
|
|
|
5 |
|
|
|
6 |
import java.text.SimpleDateFormat;
|
|
|
7 |
import java.util.Calendar;
|
|
|
8 |
import java.util.Date;
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* Custom Serializer for dateTime (Calendar).
|
|
|
13 |
*
|
|
|
14 |
*/
|
|
|
15 |
public class CustomCalendarSerializer extends CalendarSerializer {
|
|
|
16 |
|
|
|
17 |
private static SimpleDateFormat zulu =
|
|
|
18 |
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
|
|
19 |
|
|
|
20 |
public String getValueAsString(Object value, SerializationContext context) {
|
|
|
21 |
Date date = value instanceof Date ? (Date) value : ((Calendar) value).getTime();
|
|
|
22 |
// Serialize to String
|
|
|
23 |
synchronized (zulu) {
|
|
|
24 |
// SimpleDateFormat returns offset in hhmm format
|
|
|
25 |
// change it to return in hh:mm format
|
|
|
26 |
return zulu.format(date).replaceAll("(\\d\\d)$", ":$1");
|
|
|
27 |
}
|
|
|
28 |
}
|
|
|
29 |
}
|