public static DateTimeComponents parse ( String dateString , Boolean hasTime ) { Matcher m = regex . matcher ( dateString ) ; if ( ! m . find ( ) ) { throw Messages . INSTANCE . getIllegalArgumentException ( 19 , dateString ) ; } int i = 1 ; int year = Integer . parseInt ( m . group ( i ++ ) ) ; int month = Integer . parseInt ( m . group ( i ++ ) ) ; int date = Integer . parseInt ( m . group ( i ++ ) ) ; i ++ ; //skip String hourStr = m . group ( i ++ ) ; if ( hasTime == null ) { hasTime = ( hourStr != null ) ; } if ( ! hasTime ) { return new DateTimeComponents ( year , month , date ) ; } int hour = ( hourStr == null ) ? 0 : Integer . parseInt ( hourStr ) ; String minuteStr = m . group ( i ++ ) ; int minute = ( minuteStr == null ) ? 0 : Integer . parseInt ( minuteStr ) ; String secondStr = m . group ( i ++ ) ; int second = ( secondStr == null ) ? 0 : Integer . parseInt ( secondStr ) ; boolean utc = "Z" . equals ( m . group ( i ++ ) ) ; return new DateTimeComponents ( year , month , date , hour , minute , second , utc ) ; }
Parses the components out of a date - time string .