public Date dateTime ( ImapRequestLineReader request ) throws ProtocolException { char next = request . nextWordChar ( ) ; String dateString ; // From https://tools.ietf.org/html/rfc3501 : // date-time = DQUOTE date-day-fixed "-" date-month "-" date-year // SP time SP zone DQUOTE // zone = ("+" / "-") 4DIGIT if ( next == ' ' ) { dateString = consumeQuoted ( request ) ; } else { throw new ProtocolException ( "DateTime values must be quoted." ) ; } try { // You can use Z or zzzz return new SimpleDateFormat ( "dd-MMM-yyyy hh:mm:ss Z" , Locale . US ) . parse ( dateString ) ; } catch ( ParseException e ) { throw new ProtocolException ( "Invalid date format <" + dateString + ">, should comply to dd-MMM-yyyy hh:mm:ss Z" ) ; } }
Reads a date - time argument from the request .