Converter (Date to Japanese calendar text)

Converter (Date to Japanese calendar text)

コンバータ (Date to 和暦テキスト)

This item converts a Date / Datetime type data item to Japanese calendar text and stores it in a String type data item.

Auto Step icon
Basic Configs
Step Name
Note
Configs for this Auto Step
conf_DataIdA
C1: Date / Datetime type data item to be converted *
conf_DataIdB
C2: String type data item to save Japanese calendar text *

Notes

  • Only the date part is converted, the time part is not converted.

Capture

See also

Script (click to open)
  • An XML file that contains the code below is available to download
    • converter-dateToJpEra.xml (C) Questetra, Inc. (MIT License)
    • If you are using Professional, you can modify the contents of this file and use it as your own add-on auto step


function main() {
  // データの参照
  const dData = engine.findDataByNumber(configs.get("conf_DataIdA"));
  if (dData === null) {
    // 日付 / 日時型データが空なら、処理失敗に
    throw "DATE/DATETIME Data is empty";
  }

  //元号変換
  // 1900-01-01 = 明治33年1月1日
  // 1912-07-29 = 明治45年7月29日
  // 1912-07-30 = 大正元年7月30日
  // 1926-12-24 = 大正15年12月24日
  // 1926-12-25 = 昭和元年12月25日
  // 1989-01-07 = 昭和64年1月7日
  // 1989-01-08 = 平成元年1月8日
  // 2019-04-30 = 平成31年4月30日
  // 2019-05-01 = 令和元年5月1日
  const locale = new java.util.Locale("ja", "JP", "JP");
  const formatter = new java.text.SimpleDateFormat("GGGGyyyy年M月d日", locale);
  const text = formatter.format(dData);

  //データ更新
  engine.setDataByNumber(configs.get("conf_DataIdB"), text);
}
Scroll to Top

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading