Updated code for pdf tabel updation
This commit is contained in:
@@ -4,12 +4,18 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.itextpdf.styledxmlparser.jsoup.Jsoup;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -369,5 +375,25 @@ public class Utils {
|
||||
throw new RuntimeException("Error converting map to string", e);
|
||||
}
|
||||
}
|
||||
public static boolean isValidDateString(String dateStr) {
|
||||
Pattern datePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}");
|
||||
return datePattern.matcher(dateStr).matches();
|
||||
}
|
||||
|
||||
// Method to convert a valid date string to the "dd-MM-yyyy" format
|
||||
public static String formatDateString(String dateStr) {
|
||||
String originalFormatPattern = "yyyy-MM-dd'T'HH:mm:ss";
|
||||
String targetFormatPattern = "dd-MM-yyyy";
|
||||
|
||||
try {
|
||||
SimpleDateFormat originalFormat = new SimpleDateFormat(originalFormatPattern);
|
||||
Date date = originalFormat.parse(dateStr);
|
||||
SimpleDateFormat targetFormat = new SimpleDateFormat(targetFormatPattern);
|
||||
|
||||
return targetFormat.format(date);
|
||||
} catch (ParseException e) {
|
||||
log.error("error while prcoessing date formate");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user