Date Modification
You've now seen currency formatting. What about dates? Formatting these is also quite straightforward. In the preceding program output, I displayed the date using the class DateFormat. As it happens, this class helps you to format and parse dates for any locale.
For example, to format a date for a different locale, you specify the required locale in the call to getDateInstance():
DateFormat df = DateFormat.getDateInstance( DateFormat.LONG, Locale.FRANCE); System.out.println(df.format(order.dateOfOrderCreation));
Inserting the above code into the Charging aspect produces the following output:
Created an instance of StockItem Created another instance of StockItem Now routing the order to billing Now in the after code Date of order origination Fri Jul 07 12:21:48 BST 2006 7 juillet 2006 Calculated order value 670.576 Order is complete, ready for reporting Retrieved order value $670.58 Order has a value of 670.576
Notice that the date on the sixth line is now in French: 7 juillet 2006.
Clearly, all the I18N code could be added to another aspect and then invoked from the Charging aspect.