android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/android-ibc-forum.git
Log | Files | Refs

Dates.java (1359B)


      1 /*
      2  * Copyright (C) 2010 A. Horn
      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 at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * 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 and
     14  * limitations under the License.
     15  */
     16 
     17 package org.mcsoxford.rss;
     18 
     19 import java.text.ParseException;
     20 import java.text.SimpleDateFormat;
     21 
     22 /**
     23  * Internal helper class for date conversions.
     24  * 
     25  * @author Mr Horn
     26  */
     27 final class Dates {
     28 
     29   /**
     30    * @see <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC 822</a>
     31    */
     32   private static final SimpleDateFormat RFC822 = new SimpleDateFormat(
     33       "EEE, dd MMM yyyy HH:mm:ss Z", java.util.Locale.ENGLISH);
     34 
     35   /* Hide constructor */
     36   private Dates() {}
     37   
     38   /**
     39    * Parses string as an RFC 822 date/time.
     40    * 
     41    * @throws RSSFault if the string is not a valid RFC 822 date/time
     42    */
     43   static java.util.Date parseRfc822(String date) {
     44     try {
     45       return RFC822.parse(date);
     46     } catch (ParseException e) {
     47       throw new RSSFault(e);
     48     }
     49   }
     50 
     51 }
     52