diff --git a/src/org/kar/archidata/tools/DateTools.java b/src/org/kar/archidata/tools/DateTools.java index 68a096a..9ce9040 100644 --- a/src/org/kar/archidata/tools/DateTools.java +++ b/src/org/kar/archidata/tools/DateTools.java @@ -1,7 +1,6 @@ package org.kar.archidata.tools; import java.io.IOException; -import java.text.ParseException; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -39,6 +38,15 @@ public class DateTools { return parseOffsetDateTime(dateString, false); } + /** + * Attempts to parse a date string into an OffsetDateTime using a flexible list of patterns. + * Supports ISO 8601 formats, optional zone, and fallback to LocalDate or LocalTime if needed. + * + * @param dateString the date string to parse + * @param missingAsUTC Parse date when missing the time zone consider it as a UTC Date-time + * @return OffsetDateTime representation of the parsed input + * @throws IOException if no supported format matches the input + */ public static OffsetDateTime parseOffsetDateTime(final String dateString, final boolean missingAsUTC) throws IOException { if (dateString == null) { @@ -66,11 +74,11 @@ public class DateTools { /** * Parses a flexible date string and returns a java.util.Date, - * using system default timezone for conversion. + * using system default time-zone for conversion. * * @param dateString the input string to parse - * @return java.util.Date object - * @throws ParseException if parsing fails entirely + * @return The parsed Date + * @throws IOException if parsing fails. */ public static Date parseDate(final String dateString) throws IOException { final OffsetDateTime dateTime = parseOffsetDateTime(dateString, true); diff --git a/src/org/kar/archidata/tools/RESTApiRequest.java b/src/org/kar/archidata/tools/RESTApiRequest.java index 64f9fec..a095ff6 100644 --- a/src/org/kar/archidata/tools/RESTApiRequest.java +++ b/src/org/kar/archidata/tools/RESTApiRequest.java @@ -69,7 +69,7 @@ public class RESTApiRequest { /** * Sets the request body as a raw String. * - * @param body The raw string body. + * @param body The raw string body. * @param contentType The content type of the request body. * @return The updated RESTApiRequest instance. */ @@ -83,8 +83,7 @@ public class RESTApiRequest { /** * Sets the request body as a raw String. * - * @param body The raw string body (consider as "text/plain"). - * @param contentType The content type of the request body. + * @param body The raw string body (consider as "text/plain"). * @return The updated RESTApiRequest instance. */ public RESTApiRequest bodyString(final String body) { @@ -136,11 +135,10 @@ public class RESTApiRequest { } /** - * Sed data as a json body. + * Set data as a json body. * * @param body a serialized Json object. * @return The updated RESTApiRequest instance. - * @throws JsonProcessingException If serialization fails. */ public RESTApiRequest bodyAsJson(final String body) { this.serializedBodyString = body; @@ -316,11 +314,11 @@ public class RESTApiRequest { * *

This method encodes each key and value using UTF-8 encoding to ensure that * the resulting query string is safe for use in a URL. The encoded key-value pairs - * are then joined together with '&' separators.

+ * are then joined together with `&` separators.

* * @param params A map containing query parameter names and their corresponding values. * Both keys and values will be URL-encoded. - * @return A URL-encoded query string (e.g., "name=John+Doe&age=30") + * @return A URL-encoded query string. */ public static String buildQueryParams(final Map params) { return params.entrySet().stream().map(entry -> URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8) + "="