XmlRpcDateTimeDateFormat.java
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing,
00013  * software distributed under the License is distributed on an
00014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00015  * KIND, either express or implied.  See the License for the
00016  * specific language governing permissions and limitations
00017  * under the License.    
00018  */
00019 package org.apache.xmlrpc.util;
00020 
00021 import java.text.FieldPosition;
00022 import java.text.ParsePosition;
00023 import java.util.Calendar;
00024 import java.util.Date;
00025 
00026 
00027 
00031 public abstract class XmlRpcDateTimeDateFormat extends XmlRpcDateTimeFormat {
00032     private static final long serialVersionUID = -5107387618606150784L;
00033 
00034     public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
00035         final Object cal;
00036         if (pCalendar != null  &&  pCalendar instanceof Date) {
00037             Calendar calendar = Calendar.getInstance(getTimeZone());
00038             calendar.setTime((Date) pCalendar);
00039             cal = calendar;
00040         } else {
00041             cal = pCalendar;
00042         }
00043         return super.format(cal, pBuffer, pPos);
00044     }
00045 
00046     public Object parseObject(String pString, ParsePosition pParsePosition) {
00047         Calendar cal = (Calendar) super.parseObject(pString, pParsePosition);
00048         return cal == null ? null : cal.getTime();
00049     }
00050 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49