diff --git a/apps/addressbook/java/src/net/i2p/addressbook/DeletedHosts.java b/apps/addressbook/java/src/net/i2p/addressbook/DeletedHosts.java index b3afa653e..d4ba7c259 100644 --- a/apps/addressbook/java/src/net/i2p/addressbook/DeletedHosts.java +++ b/apps/addressbook/java/src/net/i2p/addressbook/DeletedHosts.java @@ -205,7 +205,7 @@ public class DeletedHosts { PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(_file), "UTF-8"))); - out.println("# Last saved: " + DataHelper.formatTime(System.currentTimeMillis())); + out.println("# Last saved: " + DataHelper.formatTimeNormalSpaces(System.currentTimeMillis())); out.print(HELP); for (String s : entries) { out.println(s); diff --git a/apps/addressbook/java/src/net/i2p/addressbook/Log.java b/apps/addressbook/java/src/net/i2p/addressbook/Log.java index 72951054f..c304a3e80 100644 --- a/apps/addressbook/java/src/net/i2p/addressbook/Log.java +++ b/apps/addressbook/java/src/net/i2p/addressbook/Log.java @@ -62,7 +62,7 @@ class Log { try { bw = new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(this.file, true), "UTF-8")); - String timestamp = DataHelper.formatTime(I2PAppContext.getGlobalContext().clock().now()); + String timestamp = DataHelper.formatTimeNormalSpaces(I2PAppContext.getGlobalContext().clock().now()); bw.write(timestamp + " -- " + entry); bw.newLine(); } catch (IOException exp) { diff --git a/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java b/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java index 074bf01f8..6b6e348cc 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java +++ b/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java @@ -925,7 +925,7 @@ public class I2PSnarkUtil implements DisconnectListener { fos = new SecureFileOutputStream(tmpFile); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"))); out.println("# NOTE: This I2P config file must use UTF-8 encoding"); - out.println("# Last saved: " + DataHelper.formatTime(System.currentTimeMillis())); + out.println("# Last saved: " + DataHelper.formatTimeNormalSpaces(System.currentTimeMillis())); for (Map.Entry entry : props.entrySet()) { String name = (String) entry.getKey(); String val = (String) entry.getValue(); diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 17cce3f76..9bdc426ec 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -559,7 +559,7 @@ public class DataHelper { if (file.getName().equals("router.config")) out.println("# WARNING: Do NOT copy this file from one router to another, this may cause serious problems."); out.println("# NOTE: This I2P config file must use UTF-8 encoding"); - out.println("# Last saved: " + formatTime(System.currentTimeMillis())); + out.println("# Last saved: " + formatTimeNormalSpaces(System.currentTimeMillis())); for (Map.Entry entry : props.entrySet()) { String name = (String) entry.getKey(); String val = (String) entry.getValue(); @@ -1739,7 +1739,7 @@ public class DataHelper { * The default formatting for date/time, current locale, local time zone. * Warning - NOT UTC! * Warning - may contain UTF-8 chars, output format may change between Java versions. - * As of Java 21, space before the AM/PM is a narrow no-break space U+202F, + * As of Java 20, space before the AM/PM is a narrow no-break space U+202F, * or e2 80 af. * * Examples: @@ -1758,6 +1758,23 @@ public class DataHelper { return TIME_FORMAT.format(new Date(now)); } } + + /** + * The default formatting for date/time, current locale, local time zone, + * EXCEPT UTF-8 spaces are replaced with normal spaces. + * ref: https://inside.java/2024/03/29/quality-heads-up/ + * + * Warning - NOT UTC! + * Warning - may contain other UTF-8 chars, output format may change between Java versions. + * + * Examples: + * en: Aug 30, 2019 12:38 PM + * de: 30.08.2019 12:38 + * @since 0.9.71 + */ + public static String formatTimeNormalSpaces(long now) { + return formatTime(now).replace('\u202F', ' ').replace('\u00A0', ' '); + } /** * Strip out any HTML (simply removing any less than / greater than symbols)