@SuppressWarnings({"HardCodedStringLiteral"}) private static void initDateFormats() { EXPECTED_DATE_FORMATS[0] = new SyncDateFormat(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US)); EXPECTED_DATE_FORMATS[0].setTimeZone(TimeZone.getTimeZone("GMT")); EXPECTED_DATE_FORMATS[1] = new SyncDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US)); EXPECTED_DATE_FORMATS[1].setTimeZone(TimeZone.getTimeZone("GMT")); }
private void processRevisionDate(String line) { // a line may looks like: // date: 2003/02/20 14:52:06; author: tom; state: Exp; lines: +1 -1; kopt: o; commitid: 3803e54eb96167d; // or: // date: 2003/01/11 17:56:27; author: tom; state: Exp; final StringTokenizer token = new StringTokenizer(line, ";", false); if (token.hasMoreTokens()) { final String date = token.nextToken(); final String dateString = date.substring(DATE.length()); Date parsedDate = null; for (SyncDateFormat expectedDateFormat : EXPECTED_DATE_FORMATS) { try { parsedDate = expectedDateFormat.parse(dateString); } catch (ParseException e) { //ignore } if (parsedDate != null) break; } if (parsedDate != null) { revision.setDate(parsedDate); } else { BugLog.getInstance().showException(new Exception(JavaCvsSrcBundle.message("line.could.not.be.parsed.error.message", line))); } } if (token.hasMoreTokens()) { final String author = token.nextToken(); if (author.startsWith(AUTHOR)) { revision.setAuthor(author.substring(AUTHOR.length())); } } if (token.hasMoreTokens()) { final String state = token.nextToken(); if (state.startsWith(STATE)) { revision.setState(state.substring(STATE.length())); } } if (token.hasMoreTokens()) { final String linesModified = token.nextToken(); if (linesModified.startsWith(LINES)) { revision.setLines(linesModified.substring(LINES.length())); } } processingRevision = true; logMessageBuffer = new ArrayList<String>(); }