Spread.Sheets Documentation
Setting the Era Format
Spread.Sheets Documentation > Developer's Guide > Managing Data > Setting the Era Format

You can specify format settings for the era if the culture has been set to "ja-jp".

The following table lists the format options and the Japanese and English culture equivalents.

Keyword Japanese Culture English Culture
g Display the era name in alphabet (M, T, S, H)  
gg Display the first character (DBCS) era (明, 大, 昭, 平)  
ggg Display the full (DBCS) era (明治, 大正, 昭和, 平成)  
gggg (plus any additional "g" characters) Same as "ggg"  
e Display the nengo year as a single digit number when possible (1-??) Same as "y"
ee Display the nengo year as a two digit number when possible (01-??) Same as "yy"
eee (plus any additional "e" characters) Same as "ee" Same as "yyyy"
y Same as 'e' when after 'g'; otherwise, same as en culture Display the year as a number without a leading zero (0 - 99)
yy Same as 'ee' when after 'g'; otherwise, same as en culture Display the year as a number with a leading zero (00 - 99)
yyy Same as 'ee' when after 'g'; otherwise, same as en culture Display the year as a number without a leading zero (1 - 9999)
yyyy Same as 'ee' when after 'g'; otherwise, same as en culture Same as "yyy"

Using Code

The following example sets the era formatting.

JavaScript
Copy Code
GC.Spread.Common.CultureInfo.eras = [{name: "明治", abbreviation: "明",  symbol: "M", startDate: "1868-09-08", shortcuts: "1,M"},
{name: "大正", abbreviation: "大",  symbol: "T", startDate: "1912-07-30", shortcuts: "2,T"},
{name: "昭和", abbreviation: "昭",  symbol: "S" , startDate: "1926-12-25", shortcuts: "3,S"},
{name: "平成 Test", abbreviation: "平",  symbol: "H", startDate: "1989-01-08", shortcuts: "4,H"}]

Using Code

The following example formats a date in a cell.

JavaScript
Copy Code
var f = new GC.Spread.Formatter.GeneralFormatter("ggg ee/MM/dd dddd", "ja-jp");
activeSheet.getCell(1,1).formatter(f);
activeSheet.getCell(1,1).value(new Date(2014,00,20));
// Or
GC.Spread.Common.CultureManager.culture("ja-jp");
activeSheet.getCell(1,1).formatter("ggg ee/MM/dd dddd");
activeSheet.getCell(1,1).value(new Date(2014,00,20));
//Or
activeSheet.getCell(1,1).formatter("[$-411]ggg ee/MM/dd dddd");
activeSheet.getCell(1,1).value(new Date(2014,00,20));
See Also