Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

当 culture 设置为 “ja-jp” 时,你可以设置日本的年号。

下表描述了日文和英文的日期格式对比:


关键字日文 Culture英文 Culture
g显示英文的年号 (M, T, S, H) 
gg显示年号的第一个字 (DBCS) (明, 大, 昭, 平) 
ggg显示全部年号 (DBCS) (明治, 大正, 昭和, 平成) 
gggg (plus any additional "g" characters)等同于 "ggg" 
e如果可以,将年号永一位数字表示 (1-??)等同于 "y"
ee如果可以,将年号用两位数字表示 (01-??)Same as "yy"
eee (plus any additional "e" characters)等同于 "ee"Same as "yyyy"
y当在'g'之后时等同于 'e' 否则, 和 en culture 一样。显示二位数年 ,(0 - 99),没有前导0。
yy当在'g'之后时等同于 'e' 否则, 和 en culture 一样。显示二位数年,包含前导0 (00 - 99)
yyy当在'g'之后时等同于 'e' 否则, 和 en culture 一样。Display the year as a number without a leading zero (1 - 9999)
yyyy当在'g'之后时等同于 'e' 否则, 和 en culture 一样。等同于 "yyy"

示例代码

以下代码使用了日本年号。

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"}]

示例代码

以下代码设置了单元格日期中的格式。

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));


另见
Setting the Culture
Formatting Cells

  • No labels