From ff099422bdc18b9ebba688989b4bb222a1a14841 Mon Sep 17 00:00:00 2001 From: phib Date: Mon, 1 Feb 2010 23:55:54 +0000 Subject: [PATCH] 2944204 Language util fails to parse some java date formats Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2944204 --- base/src/org/compiere/util/Language.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/base/src/org/compiere/util/Language.java b/base/src/org/compiere/util/Language.java index 043a4ff2b2..d967ca378a 100644 --- a/base/src/org/compiere/util/Language.java +++ b/base/src/org/compiere/util/Language.java @@ -609,21 +609,13 @@ public class Language implements Serializable m_dateFormat = (SimpleDateFormat)DateFormat.getDateInstance (DateFormat.SHORT, m_locale); String sFormat = m_dateFormat.toPattern(); - // some short formats have only one M and d (e.g. ths US) - if (sFormat.indexOf("MM") == -1 && sFormat.indexOf("dd") == -1) - { - String nFormat = ""; - for (int i = 0; i < sFormat.length(); i++) + // some short formats have only one M and/or d (e.g. ths US) + if (sFormat.indexOf("MM") == -1 || sFormat.indexOf("dd") == -1) { - if (sFormat.charAt(i) == 'M') - nFormat += "MM"; - else if (sFormat.charAt(i) == 'd') - nFormat += "dd"; - else - nFormat += sFormat.charAt(i); - } + sFormat = sFormat.replaceFirst("d+", "dd"); + sFormat = sFormat.replaceFirst("M+", "MM"); // log.finer(sFormat + " => " + nFormat); - m_dateFormat.applyPattern(nFormat); + m_dateFormat.applyPattern(sFormat); } // Unknown short format => use JDBC if (m_dateFormat.toPattern().length() != 8)