DateConverter { public Model getNepaliDate(@IntRange(from = 1913 - 2033) int engYY, @IntRange(from = 1, to = 12) int engMM, @IntRange(from = 1, to = 31) int engDD) { if (isEngDateInConversionRange(engYY, engMM, engDD)) { int startingEngYear = 1913; int startingEngMonth = 4; int startingEngDay = 13; int startingDayOfWeek = Calendar.SUNDAY; int startingNepYear = 1970; int startingNepMonth = 1; int startingNepDay = 1; int nepYY, nepMM, nepDD; int dayOfWeek = startingDayOfWeek; Model tempModel = new Model(); DateTime base = new DateTime(startingEngYear, startingEngMonth, startingEngDay, 0, 0); DateTime newDate = new DateTime(engYY, engMM, engDD, 0, 0); long totalEngDaysCount = Days.daysBetween(base, newDate).getDays(); nepYY = startingNepYear; nepMM = startingNepMonth; nepDD = startingNepDay; while (totalEngDaysCount != 0) { int daysInMonth = daysInMonthMap.get(nepYY)[nepMM]; nepDD++; if (nepDD > daysInMonth) { nepMM++; nepDD = 1; } if (nepMM > 12) { nepYY++; nepMM = 1; } dayOfWeek++; if (dayOfWeek > 7) { dayOfWeek = 1; } totalEngDaysCount--; } tempModel.setYear(nepYY); tempModel.setMonth(nepMM - 1); tempModel.setDay(nepDD); tempModel.setDayOfWeek(dayOfWeek); return tempModel; } else throw new IllegalArgumentException("Out of Range: Date is out of range to Convert"); } DateConverter(); Model getEnglishDate(@IntRange(from = 1970, to = 2090) int nepYY,
                                @IntRange(from = 1, to = 12) int nepMM,
                                @IntRange(from = 1, to = 32) int nepDD); @SuppressWarnings("unused") Calendar getEnglishDate(Model date); Model getNepaliDate(@IntRange(from = 1913 - 2033) int engYY,
                               @IntRange(from = 1, to = 12) int engMM,
                               @IntRange(from = 1, to = 31) int engDD); @SuppressWarnings("unused") Model getNepaliDate(Calendar date); @Contract(pure = true) static int getNepaliMonthString(@IntRange(from = 0, to = 11) int month); int getFirstWeekDayMonth(@IntRange(from = 1970, to = 2090) int yy, @IntRange(from = 1, to = 12) int mm); int noOfDaysInMonth(@IntRange(from = 1970, to = 2090) int yy, @IntRange(from = 1, to = 12) int mm); int getWeekDay(@IntRange(from = 1970, to = 2090) int yy, @IntRange(from = 1, to = 12) int mm, @IntRange(from = 1, to = 32) int dd); Model getTodayNepaliDate(); @SuppressWarnings("unused") static Calendar convertModelToCalendar(Model tempModel); @SuppressWarnings("unused") static Model convertCalendarToModel(Calendar date); static ArrayList<Model> getAllSaturdays();  }
@Test public void getNepaliDate() { Model nepaliDate = new Model(2073, 11, 7); Calendar englishDate = dc.getEnglishDate(nepaliDate); assertThat(englishDate.get(Calendar.DAY_OF_MONTH), is(18)); assertThat(englishDate.get(Calendar.MONTH), is(1)); assertThat(englishDate.get(Calendar.YEAR), is(2017)); }