Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit bf1f5bb

Browse files
authored
DateUtil & GUID deprecation (#26)
1 parent 658b48f commit bf1f5bb

File tree

2 files changed

+29
-61
lines changed

2 files changed

+29
-61
lines changed
Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,54 @@
11
package com.genexus.JWT.utils;
22

33
import java.time.LocalDateTime;
4-
import java.time.LocalTime;
54
import java.time.format.DateTimeFormatter;
6-
import java.time.format.DateTimeParseException;
7-
import java.time.temporal.ChronoField;
8-
import java.util.Calendar;
95

106
import com.genexus.commons.DateUtilObject;
117

8+
/***** DEPRECATED OBJECT SINCE GeneXus 16 upgrade 11 ******/
9+
1210
public final class DateUtil extends DateUtilObject {
1311

1412
/******** EXTERNAL OBJECT PUBLIC METHODS - BEGIN ********/
13+
14+
/**
15+
* @deprecated DateUtil object is deprecated. Use GeneXus DateTime data type
16+
* instead
17+
* https://wiki.genexus.com/commwiki/servlet/wiki?7370,DateTime%20data%20type
18+
*/
19+
@Deprecated
1520
public String getCurrentDate() {
1621
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
1722
LocalDateTime now = LocalDateTime.now();
1823
return dtf.format(now);
1924
}
2025

26+
/**
27+
* @deprecated DateUtil object is deprecated. Use GeneXus DateTime data type
28+
* instead
29+
* https://wiki.genexus.com/commwiki/servlet/wiki?7370,DateTime%20data%20type
30+
*/
31+
@Deprecated
2132
public String currentPlusSeconds(long seconds) {
2233
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
2334
LocalDateTime now = LocalDateTime.now();
2435
LocalDateTime aux = now.plusSeconds(seconds);
2536
return dtf.format(aux);
2637
}
2738

39+
/**
40+
* @deprecated DateUtil object is deprecated. Use GeneXus DateTime data type
41+
* instead
42+
* https://wiki.genexus.com/commwiki/servlet/wiki?7370,DateTime%20data%20type
43+
*/
44+
@Deprecated
2845
public String currentMinusSeconds(long seconds) {
2946
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
3047
LocalDateTime now = LocalDateTime.now();
3148
LocalDateTime aux = now.minusSeconds(seconds);
3249
return dtf.format(aux);
3350
}
3451

35-
public String currentPlusMinutes(long minutes) {
36-
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
37-
LocalDateTime now = LocalDateTime.now();
38-
LocalDateTime aux = now.plusMinutes(minutes);
39-
return dtf.format(aux);
40-
}
41-
42-
public String currentPlusHours(long hours) {
43-
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
44-
LocalDateTime now = LocalDateTime.now();
45-
LocalDateTime aux = now.plusHours(hours);
46-
return dtf.format(aux);
47-
}
48-
49-
public String currentPlusDays(long days) {
50-
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
51-
LocalDateTime now = LocalDateTime.now();
52-
LocalDateTime aux = now.plusDays(days);
53-
return dtf.format(aux);
54-
}
55-
56-
public String currentPlusMonths(int months) {
57-
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
58-
LocalDateTime now = LocalDateTime.now();
59-
LocalDateTime aux = now.plusMonths(months);
60-
return dtf.format(aux);
61-
}
62-
63-
public String lastDayOfCurrentMonth(String time) {
64-
LocalTime localTime;
65-
try {
66-
localTime = LocalTime.parse(time, DateTimeFormatter.ofPattern("HH:mm:ss"));
67-
} catch (DateTimeParseException e) {
68-
this.error.setError("DU001", "Wrong format in input parameter");
69-
return "";
70-
}
71-
72-
int hour = localTime.get(ChronoField.CLOCK_HOUR_OF_DAY);
73-
int minute = localTime.get(ChronoField.MINUTE_OF_HOUR);
74-
int second = localTime.get(ChronoField.SECOND_OF_MINUTE);
75-
Calendar calendar = Calendar.getInstance();
76-
int day = calendar.getActualMaximum(Calendar.DATE);
77-
LocalDateTime now = LocalDateTime.now();
78-
int year = now.getYear();
79-
int month = now.getMonthValue();
80-
String result;
81-
try {
82-
result = String.format("%d/%02d/%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
83-
} catch (java.util.IllegalFormatException e) {
84-
this.error.setError("DU002", "Could not generate correct date");
85-
return "";
86-
}
87-
return result;
88-
89-
}
90-
9152
/******** EXTERNAL OBJECT PUBLIC METHODS - END ********/
9253

9354
}

GeneXusJWT/src/main/java/com/genexus/JWT/utils/GUID.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44

55
import com.genexus.commons.GUIDObject;
66

7-
public final class GUID extends GUIDObject{
7+
/***** DEPRECATED OBJECT SINCE GeneXus 16 upgrade 11 ******/
8+
9+
public final class GUID extends GUIDObject {
810

911
/******** EXTERNAL OBJECT PUBLIC METHODS - BEGIN ********/
12+
/**
13+
* @deprecated GUID object is deprecated. USe Genexus GUID data type instead
14+
* https://wiki.genexus.com/commwiki/servlet/wiki?31772,GUID+data+type
15+
*/
16+
@Deprecated
1017
public String generate() {
1118
UUID uuid = UUID.randomUUID();
1219

0 commit comments

Comments
 (0)