Class Currency

All Implemented Interfaces:
Serializable, Comparable

public class Currency extends GeneratedCurrency
The hybris Platform currency item.

Currencies are used mainly for pricing purpose. For this reason the <codeCurrency specified in SessionContext.getCurrency() of the current JaloSession defines the default Currency of this session. All pricing information will use this Currency by default.

Some examples for the use of Currency items:

Furthermore currencies offer convenience methods for price formatting and conversion. If you want to format a price according to its currency's digits you got to do it like this:
      PriceValue pv = ...;
      String priceStr = pv.getCurrency().formatPrice( pv.getValue() );
 

Rounding a price is also provided by this class:

      Currency c = ...;
      c.setDigits( 3 );
      // now c rounds any value to 3 digits
      double rounded = c.round( 1.234567 );
 

Converting a value between two currencies can be done this way:

      Currency source = ... , target = ... ;
      source.setConversionFactor( 2 );
      target.setConversionFactor( 1 );
      target.setDigits( 1 );
      // now convert from source to target value * 1 / 2
      double result = source.convert( target , 4.44444 );
      // result should be 2.2 , since conversion does rounding to 1 target digit
 
See Also: