久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何從回歷日期轉(zhuǎn)換為格魯吉亞日期,反之亦然

How to convert from Hijri Date to Georgian Date and vice versa(如何從回歷日期轉(zhuǎn)換為格魯吉亞日期,反之亦然)
本文介紹了如何從回歷日期轉(zhuǎn)換為格魯吉亞日期,反之亦然的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在尋找一種方法來計算例如從現(xiàn)在到特定日期的天數(shù),并且我可以使用它來確定我是否處于特定時間段(例如穆哈拉姆 +- 5 天)

I am looking for a way to calculate for example how many days it is from now, to a specific Date AND that I can use to determine whether I am in a specific time period (eg. Muharram +- 5days) or not

我已經(jīng)找了 10 多個小時了,我找到的最好的東西是HijrahDate".庫java.time.chrono.HijrahDate"還有一個叫Joda Date"的東西,我很難用.

I have been looking for over 10hours now, and the best things I found were the "HijrahDate" library "java.time.chrono.HijrahDate" and something called "Joda Date", which I had difficulties to use.

推薦答案

你想使用哪種回歷?

如果您選擇沙特阿拉伯的官方日歷,則該解決方案基于 java.time.HijrahDate 會起作用.但是這個類在 Android 上至少需要 API 級別 26.示例:

If you opt for the official calendar of Saudi-Arabia then the solution based on java.time.HijrahDate would work. But this class requires at least API level 26 on Android. Example:

HijrahDate hd1 = HijrahDate.now();
HijrahDate hd2 = HijrahDate.from(LocalDate.of(2020, 5, 1));
long days = ChronoUnit.DAYS.between(hd1, hd2);

還有繼承自接口ChronoLocalDateisAfter()isBefore()等比較方法和標準的plus()方法為了確定您的日期是否在特定時間段內(nèi).

There are also comparison methods like isAfter() or isBefore() inherited from the interface ChronoLocalDate and standard plus()-methods in order to determine if your date is in a specific time period.

java.time的向后移植:

Backport of java.time:

還有一個名為 ThreetenABP 的反向移植,用于較低的 Android 版本.但請注意,它的 HijrahDate 實現(xiàn)是不同的,并且不使用沙特阿拉伯的日歷(因此您必須容忍日期轉(zhuǎn)換的差異).

There is also a backport called ThreetenABP for lower Android-versions. But be aware of the pitfall that its implementation of HijrahDate is different and does NOT use the calendar of Saudi-Arabia (so you have to tolerate differences in date conversion).

關于 Joda-Time:

如果您選擇那個(相當過時的)庫,那么您應該選擇適用于 android 的庫版本.但是,它也不支持沙特阿拉伯的日歷,但提供了四種不同的其他變體.您需要指定算法 閏年模式.

If you opt for that (rather outdated) library then you should choose the library version adapted for android. However, it does not support the calendar of Saudi-Arabia, too, but offers four different other variations. You would need to specify the algorithmic leap year pattern.

ICU4J(嵌入在 Android 中):

它的類 IslamicCalendar 提供類似于舊日歷類的樣式 java.util.Calendar 以及幾個變體,包括沙特阿拉伯的變體.要求的最低 API 級別為 24.

Its class IslamicCalendar offers a style similar to old calendar classes java.util.Calendar and also several variants including that of Saudi-Arabia. The minimum required API level is 24.

Time4A:

那是我自己寫的一個庫(作為Time4J for Android的改編).它為類 HijriCalendar 提供了多種變體,包括 Joda 變體還包括沙特阿拉伯的日歷(變體 ummalqura).它提供了所有需要的功能,如日期算術(通過 plus()- 或 minus()- 方法)、日期比較(通過 isAfter() 等).示例:

That is a library written by myself (as adaptation of Time4J for Android). It offers the class HijriCalendar with several variations including the Joda-variants but also including the calendar of Saudi-Arabia (variant ummalqura). It offers all needed features like date arithmetic (by plus()- or minus()-method), date comparison (by isAfter() etc.). Example:

String variant = HijriCalendar.VARIANT_UMALQURA;
StartOfDay startOfDay = StartOfDay.definedBy(SolarTime.ofMecca().sunset());
HijriCalendar today = HijriCalendar.nowInSystemTime(variant, startOfDay);
HijriCalendar hcal = // gregorian to Hijri conversion
    PlainDate.of(2020, 5, 1).transform(HijriCalendar.class, variant);
long days = CalendarDays.between(today, hcal).getAmount();

其他庫不支持日落作為一天的開始等功能.您的 Muharram +- 5days-request 示例可能如下所示:

Features like sunset as start of day are not supported by other libraries. Example for your Muharram +- 5days-request might look like:

CalendarDays tolerance = CalendarDays.of(5);
HijriCalendar htemp = today.with(HijriCalendar.MONTH_OF_YEAR, HijriMonth.MUHARRAM);
HijriCalendar h1 = htemp.with(HijriCalendar.DAY_OF_MONTH.minimized()).minus(tolerance);
HijriCalendar h2 = htemp.with(HijriCalendar.DAY_OF_MONTH.maximized()).plus(tolerance);
boolean inTimePeriod = !(today.isBefore(h1) || today.isAfter(h2));

這篇關于如何從回歷日期轉(zhuǎn)換為格魯吉亞日期,反之亦然的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 欧美一区二区三区在线 | 国产精品资源在线观看 | 日韩视频在线播放 | 操操操操操 | 久久久久国产 | 国产伦一区二区三区四区 | 日韩精品免费看 | 久久精品视频播放 | www精品 | 国产在线观看免费 | 亚洲欧美视频一区二区 | 99精品一区二区三区 | 91精品久久久久久久久久入口 | www.日韩高清 | 亚洲精品一区二区三区在线 | 亚洲免费一区二区 | 色噜噜亚洲男人的天堂 | 成人在线小视频 | 国产视频三区 | 高清国产一区二区 | 视频在线一区二区 | 久久久www成人免费精品 | 久久狠狠 | 毛片a区 | 天堂一区二区三区四区 | 久久久久久一区 | 日韩高清国产一区在线 | 精品视频一区二区三区在线观看 | 久久久成人免费视频 | 最新av片 | 精品在线观看一区二区 | 精品国产青草久久久久福利 | 日韩一区中文字幕 | 国产一级视频 | 97av视频 | 成人亚洲综合 | 狠狠爱综合网 | 亚洲国产精品一区二区第一页 | 欧美一区二区三区免费在线观看 | 99热这里只有精品8 激情毛片 | 婷婷毛片 |