Hijri representation (HijriDate):

- Override Date toString()
    to replace 'Jan' with Dhu'l-Hijja
    and other values.
    - PDate returns instances of HijriDate
    that return Hijri Strings.

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-12-02 01:46:56 +03:00
parent d4be36ebf8
commit a0d4fdf9f6
Signed by: Hesham
GPG Key ID: 74876157D199B09E
3 changed files with 25 additions and 7 deletions

18
src/HijriDate.java Normal file
View File

@ -0,0 +1,18 @@
import java.util.Date;
/**
* Class to be used in Hajj-sim. Overrides toString()
* Incomplete.
*/
class HijriDate extends Date {
public HijriDate(long timeInMillis) {
super(timeInMillis);
}
@Override
public String toString(){
return super.toString().replaceAll("Jan","Dhu'l-Hijja")
.replaceAll("AST", "");
}
}

View File

@ -13,13 +13,13 @@ public class MakkahCity {
private static Date allArrivedToHotelsTime;
private static final PDate firstDayTimeMan = new PDate(
new GregorianCalendar(2020, Calendar.JANUARY, 1, 4, 0, 0),
new GregorianCalendar(2020, Calendar.JANUARY, 1, 18, 0, 0)
new GregorianCalendar(1442, Calendar.JANUARY, 9, 4, 0, 0),
new GregorianCalendar(1442, Calendar.JANUARY, 9, 18, 0, 0)
);
private static final PDate lastDayTimeMan = new PDate(
new GregorianCalendar(2020, Calendar.JANUARY, 4, 12, 0, 0),
new GregorianCalendar(2020, Calendar.JANUARY, 4, 22, 0, 0)
new GregorianCalendar(1442, Calendar.JANUARY, 12, 12, 0, 0),
new GregorianCalendar(1442, Calendar.JANUARY, 12, 22, 0, 0)
);
private static PDate currenttimeManager = firstDayTimeMan;

View File

@ -35,15 +35,15 @@ public class PDate extends Calendar {
}
public Date getStartTime() {
return startCalendar.getTime();
return new HijriDate(startCalendar.getTimeInMillis());
}
public Date getEndTime(){
return endCalendar.getTime();
return new HijriDate(endCalendar.getTimeInMillis());
}
public Date getCurrentTime() {
return currentCalendar.getTime();
return new HijriDate(currentCalendar.getTimeInMillis());
}
public void step(int key, int value){