From 71e8c2f87883ca172685dc3839ee5768c414a5b1 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 16 Jul 2018 22:19:49 +0200 Subject: [PATCH] IDEMPIERE-3746 Use AD_Language.DatePattern and TimePattern --- .../src/org/compiere/model/MLanguage.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/model/MLanguage.java b/org.adempiere.base/src/org/compiere/model/MLanguage.java index c801c7f700..e5ef74332f 100644 --- a/org.adempiere.base/src/org/compiere/model/MLanguage.java +++ b/org.adempiere.base/src/org/compiere/model/MLanguage.java @@ -305,6 +305,38 @@ public class MLanguage extends X_AD_Language return false; } } + String tp = getTimePattern(); + if (is_ValueChanged("TimePattern") && tp != null && tp.length() > 0) + { + if (tp.indexOf("HH") == -1 && tp.indexOf("hh") == -1) + { + log.saveError("Error", Msg.parseTranslation(getCtx(), "@Error@ @TimePattern@ - No Hour (HH/hh)")); + return false; + } + if (tp.indexOf("mm") == -1) + { + log.saveError("Error", Msg.parseTranslation(getCtx(), "@Error@ @TimePattern@ - No Minute (mm)")); + return false; + } + if (tp.indexOf("ss") == -1) + { + log.saveError("Error", Msg.parseTranslation(getCtx(), "@Error@ @TimePattern@ - No Second (ss)")); + return false; + } + + m_dateFormat = (SimpleDateFormat)DateFormat.getTimeInstance + (DateFormat.SHORT, getLocale()); + try + { + m_dateFormat.applyPattern(tp); + } + catch (Exception e) + { + log.saveError("Error", Msg.parseTranslation(getCtx(), "@Error@ @TimePattern@ - " + e.getMessage())); + m_dateFormat = null; + return false; + } + } if (newRecord) setAD_Language_ID(); return true;