details:   https://code.openbravo.com/erp/devel/pi/rev/a88d31ec3ee1
changeset: 19068:a88d31ec3ee1
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Tue Dec 18 15:51:58 2012 +0100
summary:   related to issue 22459: added new function

diffstat:

 src/org/openbravo/erpCommon/utility/Utility.java |  37 ++++++++++++++++++++---
 1 files changed, 32 insertions(+), 5 deletions(-)

diffs (75 lines):

diff -r 699855034d6c -r a88d31ec3ee1 
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src/org/openbravo/erpCommon/utility/Utility.java  Tue Dec 18 13:12:55 
2012 +0100
+++ b/src/org/openbravo/erpCommon/utility/Utility.java  Tue Dec 18 15:51:58 
2012 +0100
@@ -35,6 +35,7 @@
 import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.sql.Connection;
+import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
@@ -2507,6 +2508,10 @@
   /**
    * Gets the date format for the organization country.
    * 
+   * @param date
+   *          Date to apply the format.
+   * @param orgid
+   *          ID of the organization.
    * 
    * @return date with the country format string applied. In case is not 
defined, a default format
    *         is applied
@@ -2530,8 +2535,27 @@
   }
 
   /**
+   * Gets the date format for the organization country.
+   * 
+   * @param timeStamp
+   *          TimeStamp to apply the format.
+   * @param orgid
+   *          ID of the organization.
+   * 
+   * @return date with the country format string applied. In case is not 
defined, a default format
+   *         is applied
+   */
+  public static String applyCountryDateFormat(Timestamp timeStamp, String 
orgid) {
+    return applyCountryDateFormat(new Date(timeStamp.getTime()), orgid);
+  }
+
+  /**
    * Gets the number format for the organization country.
    * 
+   * @param orgid
+   *          ID of the organization.
+   * @param defaultDecimalFormat
+   *          Default decimal format.
    * 
    * @return DecimalFormat for the number representation defined for the 
country.
    */
@@ -2545,16 +2569,19 @@
       OrganizationInformation orginfo = orgInfoList.get(0);
       Location location = orginfo.getLocationAddress();
       Country country = location.getCountry();
+      DecimalFormatSymbols symbols = new DecimalFormatSymbols();
+      if (country.getDecimalseparator() != null)
+        symbols.setDecimalSeparator(country.getDecimalseparator().equals("C") 
? ',' : '.');
+      if (country.getGroupingseparator() != null)
+        
symbols.setGroupingSeparator(country.getGroupingseparator().equals("C") ? ',' : 
'.');
       if (country.getNumericmask() != null) {
-        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
-        if (country.getDecimalseparator() != null)
-          
symbols.setDecimalSeparator(country.getDecimalseparator().equals("C") ? ',' : 
'.');
-        if (country.getGroupingseparator() != null)
-          
symbols.setGroupingSeparator(country.getGroupingseparator().equals("C") ? ',' : 
'.');
         DecimalFormat numberFormat = new 
DecimalFormat(country.getNumericmask());
         numberFormat.setDecimalFormatSymbols(symbols);
         return numberFormat;
       } else {
+        if (country.getDecimalseparator() != null || country.getNumericmask() 
!= null) {
+          defaultDecimalFormat.setDecimalFormatSymbols(symbols);
+        }
         return defaultDecimalFormat;
       }
     } finally {

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to