1/*2 * Copyright 2001-2008 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 */17package org.apache.juddi.subscription;
1819import java.util.Date;
20import java.util.GregorianCalendar;
2122import javax.xml.datatype.DatatypeConfigurationException;
23import javax.xml.datatype.DatatypeFactory;
24import javax.xml.datatype.Duration;
25import javax.xml.datatype.XMLGregorianCalendar;
2627import org.apache.juddi.v3.error.ErrorMessage;
28import org.apache.juddi.v3.error.FatalErrorException;
29import org.uddi.v3_service.DispositionReportFaultMessage;
30/**31 * 32 */33publicclassTypeConvertor {
34publicstatic XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date date) throws DispositionReportFaultMessage {
35 XMLGregorianCalendar result = null;
36try {
37if (date!=null) {
38 GregorianCalendar gc = new GregorianCalendar();
39 gc.setTimeInMillis(date.getTime());
4041 DatatypeFactory df = DatatypeFactory.newInstance();
42 result = df.newXMLGregorianCalendar(gc);
43 }
44 }
45catch(DatatypeConfigurationException ce) {
46thrownewFatalErrorException(newErrorMessage("errors.Unspecified"));
47 }
4849return result;
50 }
5152publicstatic Duration convertStringToDuration(String duration) throws DispositionReportFaultMessage {
53if (duration==null) returnnull;
54 Duration result = null;
55try {
5657 DatatypeFactory df = DatatypeFactory.newInstance();
58 result = df.newDuration(duration);
59 }
60catch(DatatypeConfigurationException ce) {
61thrownewFatalErrorException(newErrorMessage("errors.Unspecified"));
62 }
6364return result;
65 }
66 }