Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A204C7E2 for ; Thu, 11 Dec 2014 15:08:50 +0000 (UTC) Received: (qmail 27847 invoked by uid 500); 11 Dec 2014 15:08:50 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 27778 invoked by uid 500); 11 Dec 2014 15:08:49 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 27768 invoked by uid 99); 11 Dec 2014 15:08:49 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Dec 2014 15:08:49 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 834FAAC094D; Thu, 11 Dec 2014 15:08:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1644664 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java Date: Thu, 11 Dec 2014 15:08:49 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141211150849.834FAAC094D@hades.apache.org> Author: sebb Date: Thu Dec 11 15:08:49 2014 New Revision: 1644664 URL: http://svn.apache.org/r1644664 Log: NET-562 FTPFile.toFormattedString should print only signficant parts of the parsed date Only clear one field as doing re-enables the 'set' status for all others Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java?rev=1644664&r1=1644663&r2=1644664&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java Thu Dec 11 15:08:49 2014 @@ -121,20 +121,21 @@ public class FTPTimestampParserImpl impl /* * Sets the Calendar precision (used by FTPFile#toFormattedDate) by clearing - * the units which were not in the format used to parse the date + * the immediately preceeding unit (if any). + * Unfortunately the clear(int) method results in setting all other units. */ private static void setPrecision(int index, Calendar working) { - int i = 0; - for(i = 0; i < index; i++) { - final int field = CALENDAR_UNITS[i]; - // Just in case the analysis is wrong, stop clearing if - // field value is not the default. - final int value = working.get(field); - if (value != 0) { -// DEBUG: new Throwable("Unexpected value "+value).printStackTrace(); - break; // stop clearing any further fields - } - working.clear(field); + if (index <= 0) { // e.g. MILLISECONDS + return; + } + final int field = CALENDAR_UNITS[index-1]; + // Just in case the analysis is wrong, stop clearing if + // field value is not the default. + final int value = working.get(field); + if (value != 0) { // don't reset if it has a value +// new Throwable("Unexpected value "+value).printStackTrace(); // DEBUG + } else { + working.clear(field); // reset just the required field } }