/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * draft-ietf-drums-msg-fmt-08 in the current TimeZone. * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date in a Date object * @since JavaMail 1.2 */ public Date parse(String text, ParsePosition pos) { return parseDate(text.toCharArray(), pos, isLenient()); }
/** * Parses the given date in the format specified by * draft-ietf-drums-msg-fmt-08 in the current TimeZone. * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date in a Date object * @since JavaMail 1.2 */ public Date parse(String text, ParsePosition pos) { return parseDate(text.toCharArray(), pos, isLenient()); }
/** * Parse a Mail date into a Date object. This uses fairly * lenient rules for the format because the Mail standards * for dates accept multiple formats. * * @param string The input string. * @param position The position argument. * * @return The Date object with the information inside. */ public Date parse(String string, ParsePosition position) { MailDateParser parser = new MailDateParser(string, position); try { return parser.parse(isLenient()); } catch (ParseException e) { e.printStackTrace(); // just return a null for any parsing errors return null; } }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }
/** * Parses the given date in the format specified by * RFC 2822. * <ul> * <li>With strict parsing, obs-* tokens are unsupported. Lenient parsing * supports obs-year and obs-zone, with the exception of the 1-character * military time zones. * <li>The optional CFWS token at the end is not parsed. * <li>RFC 2822 specifies that a zone of "-0000" indicates that the * date-time contains no information about the local time zone. This class * uses the UTC time zone in this case. * </ul> * * @param text the formatted date to be parsed * @param pos the current parse position * @return Date the parsed date. In case of error, returns null. * @since JavaMail 1.2 */ @Override public Date parse(String text, ParsePosition pos) { if (text == null || pos == null) { throw new NullPointerException(); } else if (0 > pos.getIndex() || pos.getIndex() >= text.length()) { return null; } return isLenient() ? new Rfc2822LenientParser(text, pos).parse() : new Rfc2822StrictParser(text, pos).parse(); }