1
1
/*
2
2
* Zmanim Java API
3
- * Copyright (C) 2004-2024 Eliyahu Hershfeld
3
+ * Copyright (C) 2004-2025 Eliyahu Hershfeld
4
4
*
5
5
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
6
6
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
55
55
* // will sort shaah 1.6, shaah GRA, sunrise, sunset
56
56
* </pre>
57
57
*
58
- * @author © Eliyahu Hershfeld 2007-2024
58
+ * @author © Eliyahu Hershfeld 2007-2025
59
59
* @todo Add secondary sorting. As of now the {@code Comparator}s in this class do not sort by secondary order. This means that when sorting a
60
60
* {@link java.util.Collection} of <em>zmanim</em> and using the {@link #DATE_ORDER} {@code Comparator} will have the duration based <em>zmanim</em>
61
61
* at the end, but they will not be sorted by duration. This should be N/A for label based sorting.
@@ -82,16 +82,34 @@ public class Zman {
82
82
* A longer description or explanation of a <em>zman</em>.
83
83
*/
84
84
private String description ;
85
+
86
+ /**
87
+ * The location information of the <em>zman</em>.
88
+ */
89
+ private GeoLocation geoLocation ;
85
90
86
91
/**
87
- * The constructor setting a {@link Date} based <em>zman</em> and a label.
92
+ * The constructor setting a {@link Date} based <em>zman</em> and a label. In most cases you will likely want to call
93
+ * {@link #Zman(Date, GeoLocation, String)} that also sets the location.
88
94
* @param date the Date of the <em>zman</em>.
89
95
* @param label the label of the <em>zman</em> such as "<em>Sof Zman Krias Shema GRA</em>".
90
- * @see #Zman(long , String)
96
+ * @see #Zman(Date, GeoLocation , String)
91
97
*/
92
98
public Zman (Date date , String label ) {
93
- this .label = label ;
99
+ this (date , null , label );
100
+ }
101
+
102
+ /**
103
+ * The constructor setting a {@link Date} based <em>zman</em> and a label. In most cases you will likely want to call
104
+ * {@link #Zman(Date, GeoLocation, String)} that also sets the geo location.
105
+ * @param date the Date of the <em>zman</em>.
106
+ * @param geoLocation the {@link GeoLocation} of the <em>zman</em>.
107
+ * @param label the label of the <em>zman</em> such as "<em>Sof Zman Krias Shema GRA</em>".
108
+ */
109
+ public Zman (Date date , GeoLocation geoLocation , String label ) {
94
110
this .zman = date ;
111
+ this .geoLocation = geoLocation ;
112
+ this .label = label ;
95
113
}
96
114
97
115
/**
@@ -125,6 +143,22 @@ public Date getZman() {
125
143
public void setZman (Date date ) {
126
144
this .zman = date ;
127
145
}
146
+
147
+ /**
148
+ * Returns the {link TimeZone} of the <em>zman</em>.
149
+ * @return the time zone
150
+ */
151
+ public GeoLocation getGeoLocation () {
152
+ return geoLocation ;
153
+ }
154
+
155
+ /**
156
+ * Sets the {@code GeoLocation} of the <em>zman</em>.
157
+ * @param geoLocation the {@code GeoLocation} of the <em>zman</em>.
158
+ */
159
+ public void setGeoLocation (GeoLocation geoLocation ) {
160
+ this .geoLocation = geoLocation ;
161
+ }
128
162
129
163
/**
130
164
* Returns a duration based <em>zman</em> such as {@link com.kosherjava.zmanim.AstronomicalCalendar#getTemporalHour() temporal hour}
@@ -241,6 +275,12 @@ public int compare(Zman zman1, Zman zman2) {
241
275
* <Zman>
242
276
* <Label>Sof Zman Krias Shema GRA</Label>
243
277
* <Zman>1969-02-08T09:37:56.820</Zman>
278
+ * <TimeZone>
279
+ * <TimezoneName>America/Montreal</TimezoneName>
280
+ * <TimeZoneDisplayName>Eastern Standard Time</TimeZoneDisplayName>
281
+ * <TimezoneGMTOffset>-5</TimezoneGMTOffset>
282
+ * <TimezoneDSTOffset>1</TimezoneDSTOffset>
283
+ * </TimeZone>
244
284
* <Duration>0</Duration>
245
285
* <Description>Sof Zman Krias Shema GRA is 3 sha'os zmaniyos calculated from sunrise to sunset.</Description>
246
286
* </Zman>
@@ -253,6 +293,7 @@ public String toXML() {
253
293
sb .append ("<Zman>\n " );
254
294
sb .append ("\t <Label>" ).append (getLabel ()).append ("</Label>\n " );
255
295
sb .append ("\t <Zman>" ).append (getZman () == null ? "" : formatter .format (getZman ())).append ("</Zman>\n " );
296
+ sb .append ("\t " + getGeoLocation ().toXML ().replaceAll ("\n " , "\n \t " ));
256
297
sb .append ("\n \t <Duration>" ).append (getDuration ()).append ("</Duration>\n " );
257
298
sb .append ("\t <Description>" ).append (getDescription ()).append ("</Description>\n " );
258
299
sb .append ("</Zman>" );
@@ -264,10 +305,11 @@ public String toXML() {
264
305
*/
265
306
public String toString () {
266
307
StringBuilder sb = new StringBuilder ();
267
- sb .append ("\n Label:\t \t \t " ).append (this .getLabel ());
268
- sb .append ("\n Zman:\t \t \t " ).append (getZman ());
269
- sb .append ("\n Duration:\t \t \t " ).append (getDuration ());
270
- sb .append ("\n Description:\t \t \t " ).append (getDescription ());
308
+ sb .append ("\n Label:\t " ).append (this .getLabel ());
309
+ sb .append ("\n Zman:\t " ).append (getZman ());
310
+ sb .append ("\n GeoLocation:\t " ).append (getGeoLocation ().toString ().replaceAll ("\n " , "\n \t " ));
311
+ sb .append ("\n Duration:\t " ).append (getDuration ());
312
+ sb .append ("\n Description:\t " ).append (getDescription ());
271
313
return sb .toString ();
272
314
}
273
315
}
0 commit comments