public class DateFormatConverter extends Object
// 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日'
Modifier and Type | Class and Description |
---|---|
static class |
DateFormatConverter.DateFormatTokenizer |
Constructor and Description |
---|
DateFormatConverter() |
Modifier and Type | Method and Description |
---|---|
static String |
convert(Locale locale,
DateFormat df) |
static String |
convert(Locale locale,
String format) |
static String |
getJavaDatePattern(int style,
Locale locale) |
static String |
getJavaDateTimePattern(int style,
Locale locale) |
static String |
getJavaTimePattern(int style,
Locale locale) |
static String |
getPrefixForLocale(Locale locale) |
public static String convert(Locale locale, DateFormat df)
Copyright © 2020. All rights reserved.