on 03-20-2009 9:07 AM
Hi Experts,
Date, currency format and so on depends on locale. If locale changes formats change as well.
But is possible to change these formats in locale itself (change, for example, short date format in locale en_US to dd/mm/yyyy instead of mm/dd/yyyy)?
Best Regards
Price Young
Hi,
Try this code
Date currentDate = new Date ();
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
String today = df.format(currentDate);
System.out.println("Today Date "+currentDate);
SimpleDateFormat sdfInput = new SimpleDateFormat("dd/mm/yyyy");
SimpleDateFormat sdfOutput = new SimpleDateFormat ("mm/dd/yyyy");
try {
System.out.println("Date format "+sdfOutput.format((Date) sdfInput.parse(df.format(currentDate))));
} catch (ParseException e) {
System.out.print(e);
}
Regards
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there,
You need to use simpledateformat to format the date output that you want. However, note that you need to create a Date object first before you can do the manipulation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have a look at Simpledateformat
http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.