From 42a69abfd8dc6482fdc485773664c64a0d701f20 Mon Sep 17 00:00:00 2001 From: Nicolas Micoud Date: Mon, 16 Jul 2018 22:19:36 +0200 Subject: [PATCH] IDEMPIERE-3746 Use AD_Language.DatePattern and TimePattern --- .../oracle/201807161530_IDEMPIERE-3746.sql | 18 +++++++++++++++ .../201807161530_IDEMPIERE-3746.sql | 15 ++++++++++++ .../src/org/compiere/util/DisplayType.java | 23 +++++++++++++++---- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 migration/i5.1/oracle/201807161530_IDEMPIERE-3746.sql create mode 100644 migration/i5.1/postgresql/201807161530_IDEMPIERE-3746.sql diff --git a/migration/i5.1/oracle/201807161530_IDEMPIERE-3746.sql b/migration/i5.1/oracle/201807161530_IDEMPIERE-3746.sql new file mode 100644 index 0000000000..01e0c6d16c --- /dev/null +++ b/migration/i5.1/oracle/201807161530_IDEMPIERE-3746.sql @@ -0,0 +1,18 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3719 : Add display name when sending emails +-- Jul 16, 2018 3:27:06 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2018-07-16 15:27:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11175 +; + +-- Jul 16, 2018 3:27:06 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-07-16 15:27:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201884 +; + +-- Jul 16, 2018 3:27:06 PM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-07-16 15:27:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5226 +; + +SELECT register_migration_script('201807161530_IDEMPIERE-3746.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i5.1/postgresql/201807161530_IDEMPIERE-3746.sql b/migration/i5.1/postgresql/201807161530_IDEMPIERE-3746.sql new file mode 100644 index 0000000000..1cd787975b --- /dev/null +++ b/migration/i5.1/postgresql/201807161530_IDEMPIERE-3746.sql @@ -0,0 +1,15 @@ +-- IDEMPIERE-3719 : Add display name when sending emails +-- Jul 16, 2018 3:27:06 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-07-16 15:27:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11175 +; + +-- Jul 16, 2018 3:27:06 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-07-16 15:27:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201884 +; + +-- Jul 16, 2018 3:27:06 PM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-07-16 15:27:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5226 +; + +SELECT register_migration_script('201807161530_IDEMPIERE-3746.sql') FROM dual +; diff --git a/org.adempiere.base/src/org/compiere/util/DisplayType.java b/org.adempiere.base/src/org/compiere/util/DisplayType.java index e78f1c2fbb..517d8f0d72 100644 --- a/org.adempiere.base/src/org/compiere/util/DisplayType.java +++ b/org.adempiere.base/src/org/compiere/util/DisplayType.java @@ -65,6 +65,7 @@ import java.util.logging.Level; import org.adempiere.base.IDisplayTypeFactory; import org.adempiere.base.Service; +import org.compiere.model.MLanguage; /** * System Display Types. @@ -498,11 +499,20 @@ public final class DisplayType } } - if (displayType == DateTime) + MLanguage lang = MLanguage.get(Env.getCtx(), myLanguage); + + if (displayType == DateTime) { + if (!Util.isEmpty(lang.getDatePattern()) && !Util.isEmpty(lang.getTimePattern())) + return new SimpleDateFormat(lang.getDatePattern() + " " + lang.getTimePattern()); return myLanguage.getDateTimeFormat(); - else if (displayType == Time) + } + else if (displayType == Time) { + if (!Util.isEmpty(lang.getTimePattern())) + return new SimpleDateFormat(lang.getTimePattern()); return myLanguage.getTimeFormat(); - else{ + } + + else { List factoryList = Service.locator().list(IDisplayTypeFactory.class).getServices(); for(IDisplayTypeFactory factory : factoryList){ SimpleDateFormat osgiFormat = factory.getDateFormat(displayType, myLanguage, pattern); @@ -510,8 +520,11 @@ public final class DisplayType return osgiFormat; } } - - // else if (displayType == Date) + + // Date + if (!Util.isEmpty(lang.getDatePattern())) + return new SimpleDateFormat(lang.getDatePattern()); + return myLanguage.getDateFormat(); // default } // getDateFormat