Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/main/java/com/genexus/LocalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ private static boolean hasLongYear(String date)
if (!getBLANK_EMPTY_DATE() && date.indexOf(" ") != -1)
return true;

return date.length() == 10 || date.length() == 19;
return date.length() == 10 || date.length() == 19 || date.length() == 23;
}

public Date ctotex(String date, int format)
Expand Down
46 changes: 46 additions & 0 deletions java/src/test/java/com/genexus/util/TestDateMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,50 @@ public void testYearLimit(){
calendar.setTime(testDate2);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 1976);
}

@Test
public void testCtotex(){
Connect.init();

LocalUtil localUtil = new LocalUtil('.', "MDY", "24", 30, "eng");
Date testDate1 = CommonUtil.nullDate();
Date testDate2 = CommonUtil.nullDate();
Date testDate3 = CommonUtil.nullDate();
try
{
testDate1 = localUtil.ctotex("1930-01-01T00:00", 0);
testDate2 = localUtil.ctotex("2023-01-01T00:00:00", 0);
testDate3 = localUtil.ctotex("2200-12-31T00:00:00.000", 0);
}
catch (Exception e)
{ }

Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(testDate1);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 1930);
calendar.setTime(testDate2);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 2023);
calendar.setTime(testDate3);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 2200);

testDate1 = CommonUtil.nullDate();
testDate2 = CommonUtil.nullDate();
testDate3 = CommonUtil.nullDate();
try
{
testDate1 = localUtil.ctotex("29-01-01", 0);
testDate2 = localUtil.ctotex("30-01-01T00", 0);
testDate3 = localUtil.ctotex("31-12-31T00:00", 0);
}
catch (Exception e)
{ }

calendar = GregorianCalendar.getInstance();
calendar.setTime(testDate1);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 2029);
calendar.setTime(testDate2);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 1930);
calendar.setTime(testDate3);
Assert.assertTrue(calendar.get(Calendar.YEAR) == 1931);
}
}