// returns "[$-0411]dd MMMM, yyyy;@" where the [$-0411] prefix tells Excel to use the Japanese locale
String excelFormatPattern = DateFormatConverter.convert(Locale.JAPANESE, "dd MMMM, yyyy");
CellStyle cellStyle = workbook.createCellStyle();
DataFormat poiFormat = workbook.createDataFormat();
cellStyle.setDataFormat(poiFormat.getFormat(excelFormatPattern));
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle); // formats date as '2012年3月17日'
TODO Generalise this for all Excel format strings
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Logger | |
| private static Map |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| private static Map |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| tokenConversions | back to summary |
|---|---|
| private static Map<String, String> tokenConversions | |
| DateFormatConverter | back to summary |
|---|---|
| private DateFormatConverter() | |
| convert | back to summary |
|---|---|
| public static String convert(Locale locale, DateFormat df) | |
| convert | back to summary |
|---|---|
| public static String convert(Locale locale, String format) | |
| getJavaDatePattern | back to summary |
|---|---|
| public static String getJavaDatePattern(int style, Locale locale) | |
| getJavaDateTimePattern | back to summary |
|---|---|
| public static String getJavaDateTimePattern(int style, Locale locale) | |
| getJavaTimePattern | back to summary |
|---|---|
| public static String getJavaTimePattern(int style, Locale locale) | |
| getPrefixForLocale | back to summary |
|---|---|
| public static String getPrefixForLocale(Locale locale) | |
| prepareTokenConversions | back to summary |
|---|---|
| private static Map | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public static String[] | |
| public String |
| DateFormatTokenizer | back to summary |
|---|---|
| public DateFormatTokenizer(String format) | |
| getNextToken | back to summary |
|---|---|
| public String getNextToken() | |
| tokenize | back to summary |
|---|---|
| public static String[] tokenize(String format) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |