Skip to content

Commit

Permalink
feat: HttpClient, String&Date Utility classes, Transformer + updates …
Browse files Browse the repository at this point in the history
…to QueryBuilder and SObjectSelector (#70)

* add generic httpclient

* update QueryBuilder with filter list

* Add utility classes for strings and dates

* add httpclient test class

* add transformer class and interface

* update sobjectselector
  • Loading branch information
nkskaare authored Jan 2, 2025
1 parent 7de9ad3 commit 581459a
Show file tree
Hide file tree
Showing 23 changed files with 1,422 additions and 33 deletions.
55 changes: 55 additions & 0 deletions src/apex/utils/classes/DateFormatUtility.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
public class DateFormatUtility {
public class FormattingException extends Exception {
}

public static String formatDateTimeToString(DateTime inputDate) {
String formattedDate = DateTime.ValueOf(inputDate)
.format('dd MMM yyyy HH:mm');
return formattedDate;
}

public static String formatDateToString(Date inputDate, String dateFormat) {
return DateTime.newInstance(
inputDate.year(),
inputDate.month(),
inputDate.day()
)
.format(dateFormat);
}

public static DateTime parseDateTimeFromString(String dateString) {
if (dateString != null) {
return (DateTime) JSON.deserialize(
'"' + dateString + '"',
DateTime.class
);
}
return null;
}

public static Date parseDateFromString(String dateString) {
if (dateString != null) {
return (Date) JSON.deserialize('"' + dateString + '"', Date.class);
}
return null;
}

/**
* @description Takes in a list of strings and returns a date object. The list should contain the day, month and year in that order.
*
* @param dateList - A list of strings containing the day, month and year in that order.
*/
public static Date parseDateFromString(String dateString, String format) {
if (format == 'dd.MM.yyyy') {
List<String> dateList = dateString.split('\\.');

return Date.newInstance(
Integer.valueOf(dateList[2]),
Integer.valueOf(dateList[1]),
Integer.valueOf(dateList[0])
);
}

return parseDateFromString(dateString);
}
}
5 changes: 5 additions & 0 deletions src/apex/utils/classes/DateFormatUtility.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading

0 comments on commit 581459a

Please sign in to comment.