From 93bf1a85a6561b8038f3f1fcd1af120e396ac0df Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 4 Jul 2014 20:38:08 +0800 Subject: [PATCH] IDEMPIERE-2043 DB.To_Char: Formatting for display type Date not implemented for PostgreSQL --- .../src/org/compiere/db/DB_PostgreSQL.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index 0d71c429bf..05c7113916 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -51,6 +51,7 @@ import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Ini; +import org.compiere.util.Language; import org.compiere.util.Trx; import org.compiere.util.Util; import org.jfree.io.IOUtils; @@ -440,10 +441,19 @@ public class DB_PostgreSQL implements AdempiereDatabase **/ public String TO_CHAR (String columnName, int displayType, String AD_Language) { - StringBuilder retValue = new StringBuilder("CAST ("); - retValue.append(columnName); - retValue.append(" AS Text)"); - + StringBuilder retValue = null; + if (DisplayType.isDate(displayType)) { + retValue = new StringBuilder("TO_CHAR("); + retValue.append(columnName) + .append(",'") + .append(Language.getLanguage(AD_Language).getDBdatePattern()) + .append("')"); + } else { + retValue = new StringBuilder("CAST ("); + retValue.append(columnName); + retValue.append(" AS Text)"); + } + return retValue.toString(); // Numbers /* if (DisplayType.isNumeric(displayType)) @@ -462,8 +472,7 @@ public class DB_PostgreSQL implements AdempiereDatabase .append("'"); } retValue.append(")"); - //*/ - return retValue.toString(); + //*/ } // TO_CHAR /**