You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/07/29 15:15:06 UTC

(commons-net) 02/04: Extract constants from magic strings

This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit c2ad9bc031d4cd55d0e67889efc4cda92e1f03e6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 29 11:11:05 2026 -0400

    Extract constants from magic strings
---
 .../java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java  | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
index 5ffab350..65907bfd 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
@@ -59,6 +59,11 @@ import org.apache.commons.net.ftp.FTPFileEntryParserImpl;
  * @since 3.0
  */
 public class MLSxEntryParser extends FTPFileEntryParserImpl {
+
+    private static final String SDF_PATTERN = "yyyyMMddHHmmss";
+
+    private static final String SDF_PATTERN_SECS = SDF_PATTERN + ".SSS";
+
     // This class is immutable, so a single instance can be shared.
     private static final MLSxEntryParser INSTANCE = new MLSxEntryParser();
 
@@ -111,10 +116,10 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl {
         final SimpleDateFormat dateFormat;
         final boolean hasMillis;
         if (timestamp.contains(".")) {
-            dateFormat = new SimpleDateFormat("yyyyMMddHHmmss.SSS", Locale.ROOT);
+            dateFormat = new SimpleDateFormat(SDF_PATTERN_SECS, Locale.ROOT);
             hasMillis = true;
         } else {
-            dateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ROOT);
+            dateFormat = new SimpleDateFormat(SDF_PATTERN, Locale.ROOT);
             hasMillis = false;
         }
         final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");