This Project is created with session token generation and validation. Specifically implemented for DBFOT API's
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.secureapi.service;
  2. import org.springframework.stereotype.Service;
  3. import java.time.LocalDateTime;
  4. import java.time.format.DateTimeFormatter;
  5. @Service
  6. public class DateTimeUtil {
  7. public static String getCurrentDateTime() {
  8. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ddMMyyyyHHmmss");
  9. LocalDateTime now = LocalDateTime.now();
  10. return now.format(formatter);
  11. }
  12. public static String getCurrentYear() {
  13. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy");
  14. LocalDateTime now = LocalDateTime.now();
  15. return now.format(formatter);
  16. }
  17. public static String getCurrentMonth() {
  18. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
  19. LocalDateTime now = LocalDateTime.now();
  20. return now.format(formatter);
  21. }
  22. public static String getCurrentDay() {
  23. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd");
  24. LocalDateTime now = LocalDateTime.now();
  25. return now.format(formatter);
  26. }
  27. public static String getCurrentDateTimeMysql() {
  28. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  29. LocalDateTime now = LocalDateTime.now();
  30. return now.format(formatter);
  31. }
  32. }