Converter (Date to Japanese calendar text)
This item converts a Date / Datetime type data item to Japanese calendar text and stores it in a String type data item.
Configs: Common
  • Step Name
  • Note
Configs
  • A: Select DATE/DATETIME Data *
  • B: Select STRING DATA (update) *

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

main();

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);
}
%d bloggers like this: