將提供的尼泊爾日期 (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 日。
關於 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 " )) ;