将提供的尼泊尔日期 (Bikram Sambat (BS)) 转换为等效的英文日期 (AD)/公历日期。
尼泊尔历不像英国历那样有固定的月份长度。一个月中的天数不断变化,因此我们无法创建算法来查找特定尼泊尔月份和年份的天数。希望尼泊尔日历制作者能够为尼泊尔日历打造无限的日历。目前,我们在将尼泊尔日期转换为英文日期时必须使用查找表。
我们必须找到 Bikram Sambat (BS) 年的第一天到等效公历日期的映射。对您想要转换的每个尼泊尔年份执行此操作,例如 2001 Baisakh 1“13-Apr-1944”………………。 2068 拜萨克 1 “2011 年 4 月 14 日”
要了解每个月的所有天数,以下 URL 可能会有所帮助。
BS到AD转换涉及的步骤:
如果我们需要转换 2001 Ashar 6,请查找自 Bikram Sambat 年(2001 Baisakh 1)开始以来经过的天数。
Ashar 是 BS 的第三个月(Baisakh、Jestha、Ashar),如表中所示。所以过去的天数是 31+31+6-1 = 67(Baisakh 的天数+Jestha 的天数+month_of_day-1)。其中month_of_day 是需要转换的月份中的第几天。 1 被减去,因为 Baisakh 1 已经包含在内。
将经过的天数添加到公历等效日期(1944 年 4 月 13 日),例如(1944 年 4 月 13 日)+67=1944 年 6 月 19 日。这是正确转换的公历日期 2001 Ashar 6。
关于 Bikram Sambat:* https://en.wikipedia.org/wiki/Bikram_Sambat
Why Nepali year 1974 has total days 364 instead of 365 days ?
Why Nepali year 1976 has total days 366 instead of 365 days ?
Why Nepali year 1984 has total days 366 instead of 365 days ?
Why Nepali year 1988 has total days 366 instead of 365 days ?
Why Nepali year 1990 has total days 364 instead of 365 days ?
Why Nepali year 2003 has total days 366 instead of 365 days ?
Why Nepali year 2007 has total days 366 instead of 365 days ?
Why Nepali year 2011 has total days 366 instead of 365 days ?
Why Nepali year 2015 has total days 366 instead of 365 days ?
Why Nepali year 2019 has total days 366 instead of 365 days ?
Why Nepali year 2023 has total days 366 instead of 365 days ?
Why Nepali year 2026 has total days 366 instead of 365 days ?
Why Nepali year 2030 has total days 366 instead of 365 days ?
Why Nepali year 2034 has total days 366 instead of 365 days ?
Why Nepali year 2038 has total days 366 instead of 365 days ?
Why Nepali year 2042 has total days 366 instead of 365 days ?
Why Nepali year 2046 has total days 366 instead of 365 days ?
Why Nepali year 2050 has total days 366 instead of 365 days ?
Why Nepali year 2054 has total days 366 instead of 365 days ?
Why Nepali year 2057 has total days 366 instead of 365 days ?
Why Nepali year 2061 has total days 366 instead of 365 days ?
Why Nepali year 2065 has total days 366 instead of 365 days ?
Why Nepali year 2069 has total days 366 instead of 365 days ?
Why Nepali year 2073 has total days 366 instead of 365 days ?
Why Nepali year 2077 has total days 366 instead of 365 days ?
Why Nepali year 2081 has total days 366 instead of 365 days ?
Why Nepali year 2082 has total days 366 instead of 365 days ?
Why Nepali year 2085 has total days 367 instead of 365 days ?
Why Nepali year 2086 has total days 366 instead of 365 days ?
Why Nepali year 2087 has total days 366 instead of 365 days ?
Why Nepali year 2089 has total days 366 instead of 365 days ?
Why Nepali year 2090 has total days 366 instead of 365 days ?
Why Nepali year 2091 has total days 366 instead of 365 days ?
Why Nepali year 2092 has total days 366 instead of 365 days ?
Why Nepali year 2093 has total days 366 instead of 365 days ?
Why Nepali year 2095 has total days 366 instead of 365 days ?
Why Nepali year 2096 has total days 364 instead of 365 days ?
Why Nepali year 2097 has total days 366 instead of 365 days ?
Why Nepali year 2098 has total days 366 instead of 365 days ?
这是 Maven 项目。使用 pom.xml 在您最喜欢的 IDE 中导入项目。
仅运行测试
$ mvn test
使用以下命令运行主类np.com.bahadur.converter.date.nepali.DateConverterTestBed.main
$ mvn exec:java
JDK_版本 >= JDK 1.8
克隆 https://github.com/bahadurbaniya/Date-Converter-Bikram-Sambat-to-English-Date/
运行下面的命令在 Maven 存储库中本地安装 jar mvn clean install
现在可以使用代码,如下所示使用库的示例代码
在想要使用导入/生成的 jar 的项目中编写以下代码。
< dependency >
< groupId > np.com.bahadur.converter.date.nepali < /groupId >
< artifactId > NepaliEnglishDateConverter < /artifactId >
< version > 0.0. 1< /version >
< /dependency >
DateConverter dc = new DateConverter ();
System.out.println(dc.convertAdToBs( " 20-06-1982 " )) ;
DateConverter dc = new DateConverter ();
System.out.println(dc.convertBsToAd( " 06-03-2038 " )) ;