Here you can find the source of parseDateRfc822(String str)
Parameter | Description |
---|---|
str | string to parse. |
null
if the string was null or in an invalid format.
Declaration
static Date parseDateRfc822(String str)
Method Source Code
//package com.java2s;
/**/*from w ww . j a v a 2 s. c o m*/
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class Main {
/**
* Parse a string in RFC822 GMT format.
*
* @param str string to parse.
* @return parsed date, <code>null</code> if the string was <code>null</null> or in an invalid format.
*/
static Date parseDateRfc822(String str) {
if (str != null) {
try {
SimpleDateFormat dateFormater = new SimpleDateFormat(
"EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
dateFormater.setTimeZone(TimeZone.getTimeZone("GMT"));
return dateFormater.parse(str);
} catch (ParseException ex) {
return null;
}
}
return null;
}
}
Related
- parseDateLoose(String dateString)
- parseDateNewFormat(String sDate)
- parseDateNoTimeWithDelimit(String sDate, String delimit)
- parseDateOrTimeString(String aDateString, String aFormatString)
- parseDateRFC(String value)
- parseDates(String query)
- parseDateStrFormat(String strDate)
- parseDateString(String dateStr)
- parseDateString(String dateString)