I try to find the week of the year for Jewish to use it in a global app, which provides general services about the international calendar.
Asked
Active
Viewed 411 times
3
-
1See this: http://www.david-greve.de/luach-code/jewish-java.html – Saeed Hassanvand Nov 28 '18 at 10:19
2 Answers
5
You might try my lib Time4J which offers a Jewish/Hebrew calendar and use following code:
HebrewCalendar hebcal = HebrewCalendar.nowInSystemTime();
int weekOfYear = hebcal.getInt(HebrewCalendar.WEEK_OF_YEAR);
It uses the default week model/definition in Israel which starts the week on Sunday (after Sabbat).
About interoperability with java.time
:
LocalDate gregorian = hebcal.transform(PlainDate.class).toTemporalAccessor();
HebrewCalendar jewish = PlainDate.from(gregorian).transform(HebrewCalendar.class);

Meno Hochschild
- 42,708
- 7
- 104
- 126
1
You can refer the link here which provides example that might help you:
JewishCalendar israelCalendar = new JewishCalendar(5775, JewishDate.NISSAN, 7);
israelCalendar.setInIsrael(true); //set the calendar to Israel
JewishCalendar chutsLaaretzCalendar = new JewishCalendar(5775, JewishDate.NISSAN, 7);
chutsLaaretzCalendar.setInIsrael(false); //not really needed since the API defaults to false
HebrewDateFormatter hdf = new HebrewDateFormatter();
System.out.println("Date\tChutz Laaretz / Eretz Yisrael"));
for(int i = 0; i < 57; i++){
israelCalendar.forward(); //roll the date forward a day
chutsLaaretzCalendar.forward(); //roll the date forward a day
if(chutsLaaretzCalendar.getDayOfWeek() == 7){ //ignore weekdays
System.out.println(hdf.formatParsha(chutsLaaretzCalendar) + "\t" + hdf.formatParsha(israelCalendar) + " \\ " + hdf.format(chutsLaaretzCalendar));
}
}

Vebbie
- 1,669
- 2
- 12
- 18