IDEMPIERE-3746 Use AD_Language.DatePattern and TimePattern

This commit is contained in:
Nicolas Micoud 2018-07-16 22:19:36 +02:00
parent f02e7494b7
commit 42a69abfd8
3 changed files with 51 additions and 5 deletions

View File

@ -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
;

View File

@ -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
;

View File

@ -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<IDisplayTypeFactory> 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