IDEMPIERE-2043 DB.To_Char: Formatting for display type Date not implemented for PostgreSQL

This commit is contained in:
Heng Sin Low 2014-07-04 20:38:08 +08:00
parent 68b8172603
commit 93bf1a85a6
1 changed files with 15 additions and 6 deletions

View File

@ -51,6 +51,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Language;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.jfree.io.IOUtils; 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) public String TO_CHAR (String columnName, int displayType, String AD_Language)
{ {
StringBuilder retValue = new StringBuilder("CAST ("); StringBuilder retValue = null;
retValue.append(columnName); if (DisplayType.isDate(displayType)) {
retValue.append(" AS Text)"); 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 // Numbers
/* /*
if (DisplayType.isNumeric(displayType)) if (DisplayType.isNumeric(displayType))
@ -462,8 +472,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
.append("'"); .append("'");
} }
retValue.append(")"); retValue.append(")");
//*/ //*/
return retValue.toString();
} // TO_CHAR } // TO_CHAR
/** /**