Skip to content

Commit 04e83e0

Browse files
committed
replaced method 'isValidDateFormat' with 'isValidDateFormatForAstronomy'
also changed the method location to Strings class
1 parent a9ab094 commit 04e83e0

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/main/java/io/ipgeolocation/api/AstronomyParams.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import io.ipgeolocation.api.exceptions.IPGeolocationError;
44

55
import java.math.BigDecimal;
6-
import java.util.regex.Matcher;
7-
import java.util.regex.Pattern;
86

97
/**
108
* The {@code AstronomyParams} class represents parameters used for querying Astronomy
@@ -204,7 +202,7 @@ public AstronomyParamsBuilder withIPAddress(String ipAddress) {
204202
* @throws IPGeolocationError if the date format is invalid.
205203
*/
206204
public AstronomyParamsBuilder withDate(String date) {
207-
if (Strings.isNullOrEmpty(date) || !isValidDateFormat(date)) {
205+
if (Strings.isNullOrEmpty(date) || !Strings.isValidDateFormatForAstronomy(date)) {
208206
throw new IPGeolocationError("'date' must be in YYYY-MM-DD format");
209207
}
210208
this.date = date;
@@ -231,13 +229,4 @@ public AstronomyParams build() {
231229
return new AstronomyParams(location, latitude, longitude, ipAddress, date, lang);
232230
}
233231
}
234-
/** Method to validate date format as "YYYY-MM-DD".
235-
* */
236-
private static boolean isValidDateFormat(String date) {
237-
String regex = "\\d{4}-\\d{2}-\\d{2}";
238-
Pattern pattern = Pattern.compile(regex);
239-
Matcher matcher = pattern.matcher(date);
240-
return matcher.matches();
241-
}
242-
243232
}

0 commit comments

Comments
 (0)