如何将Java脚本更改为可在映射中使用的Groovy脚本

2020-08-25 05:01发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)大家好, 我有一个用于伊斯兰日...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


大家好,

我有一个用于伊斯兰日期的代码,但是该代码在Java中,如何将其更改为Groovy?

Java代码:

函数gmod(n,m){
 返回((n%m)+ m)%m;
 }

 功能kuwaiticalendar(adjust){
 今天的var =新的Date();
 如果(调整){
 调整mili = 1000 * 60 * 60 * 24 *调整;
 todaymili = today.getTime()+ adjustmili;
 今天=新日期(todaymili);
 }
 天=今天.getDate();
 月= Today.getMonth();
 年=今天.getFullYear();
 m = month + 1;
 y =年;
 if(m <3){
 y-= 1;
 m + = 12;
 }

 a = Math.floor(y/100。);
 b = 2-a + Math.floor(a/4。);
 if(y <1583)b = 0;
 if(y == 1582){
 if(m> 10)b = -10;
 if(m == 10){
 b = 0;
 if(day> 4)b = -10;
 }
 }

 jd = Math.floor(365.25 *(y + 4716))+ Math.floor(30.6001 *(m + 1))+ day + b-1524;

 b = 0;
 如果(jd> 2299160){
 a = Math.floor((jd-1867216.25)/36524.25);
 b = 1 + a-Math.floor(a/4。);
 }
 bb = jd + b + 1524;
 cc = Math.floor((bb-122.1)/365.25);
 dd = Math.floor(365.25 * cc);
 ee = Math.floor((bb-dd)/30.6001);
 天=(bb-dd)-Math.floor(30.6001 * ee);
 month = ee-1;
 if(ee> 13){
 cc + = 1;
 month = ee-13;
 }
 年= cc-4716;

 如果(调整){
 wd = gmod(jd + 1-adjust,7)+1;
 }其他{
 wd = gmod(jd + 1,7)+1;
 }

 iyear = 10631./30 .;
 epochastro = 1948084;
 时代= 1948085;

 shift1 = 8.01/60。

 z = jd-epochastro;
 cyc = Math.floor(z/10631。);
 z = z-10631 * cyc;
 j = Math.floor((z-shift1)/iyear);
 iy = 30 * cyc + j;
 z = z-Math.floor(j * iyear + shift1);
 im = Math.floor((z + 28.5001)/29.5);
 if(im == 13)im = 12;
 id = z-Math.floor(29.5001 * im-29);

 var myRes = new Array(8);

 myRes [0] =天; //计算天数(CE)
 myRes [1] = month-1; //计算月份(CE)
 myRes [2] =年; //计算年份(CE)
 myRes [3] = jd-1; //朱利安天数
 myRes [4] = wd-1; //工作日号码
 myRes [5] = id; //伊斯兰日期
 myRes [6] = im-1; //伊斯兰月份
 myRes [7] = iy; //伊斯兰年

 返回myRes;
 }
 函数writeIslamicDate(adjustment){
 var wdNames = new Array(" Ahad"," Ithnin"," Thulatha"," Arbaa"," Khams"," Jumuah"," Sabt");
 var iMonthNames = new Array(" Muharram"," Safar"," Rabi'ul Awwal"," Rabi'ul Akhir",
 " Jumadal Ula"," Jumadal Akhira"," Rajab"," Sha'ban",
 " Ramadan"," Shawwal"," Dhul Qa'ada"," Dhul Hijja");
 var iDate = kuwaiticalendar(adjustment);
 var outputIslamicDate = wdNames [iDate [4]] +","
 + iDate [5] +"" + iMonthNames [iDate [6]] +"" + iDate [7] +" AH";
 返回outputIslamicDate;
 } 

致谢,
桑迪亚

4条回答
梦想连接
2020-08-25 06:03

嗨,Evgeniy,
如何在映射中使用它?

致谢,
桑迪亚

一周热门 更多>