// ? 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so. // import org.joda.time.*; // import org.joda.time.format.*;
DateTime now = DateTime.now();
// Style is defined by a pair of letters, one for date portion, the other for time portion. // Letters are the first letter from: Short/Medium/Long/Full // This example might be appropriate for a French person in Puducherry India (formerly Pondicherry, ex-colony of France).
DateTimeFormatter formatter = DateTimeFormat.forStyle("SS").withLocale(Locale.FRENCH).withZone( DateTimeZone.forID("Asia/Kolkata")); String dateTimeString = formatter.print( now ); System.out.println("dateTimeString:"+ dateTimeString +" for:"+ now );
// By comparison.
DateTimeFormatter formatter_FF = DateTimeFormat.forStyle("FF").withLocale(Locale.FRENCH).withZone( DateTimeZone.forID("Asia/Kolkata")); String dateTimeString_FF = formatter_FF.print( now ); System.out.println("dateTimeString_FF:"+ dateTimeString_FF +" for:"+ now );
运行时(我的默认时区是美国西海岸)......
1 2
dateTimeString:26/12/13 02:35for:2013-12-25T13:05:09.282-08:00
dateTimeString_FF: jeudi 26 décembre 2013 02 h 44 IST for:2013-12-25T13:14:41.841-08:00