Skip to content

Commit

Permalink
Merge pull request #975 from ashitsalesforce/master
Browse files Browse the repository at this point in the history
Additional date conversion tests
  • Loading branch information
ashitsalesforce authored Feb 10, 2024
2 parents c509a95 + 85c0d13 commit 6ee3f84
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/test/java/com/salesforce/dataloader/dyna/DateConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.apache.commons.beanutils.ConversionException;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import com.salesforce.dataloader.util.AppUtil;
Expand Down Expand Up @@ -325,23 +326,35 @@ public void testDegreesOfPrecisionInTimeString() {
*/
@Test
public void testDateOnly() {

testDateOnly(true);
testDateOnly(false);
}

private void testDateOnly(boolean useEuropeanDateFormat) {
Calendar expCalDate = Calendar.getInstance(TZ);

expCalDate.clear();
expCalDate.set(2004, 03, 29);

assertValidDate("2004-04-29 00:00:00z", expCalDate, false);
assertValidDate("2004-04-29 00:00:00", expCalDate, false);
assertValidDate("2004-04-29 00:00", expCalDate, false);
assertValidDate("2004-04-29 00", expCalDate, false);
assertValidDate("2004-04-29", expCalDate, false);
assertValidDate("2004-04-29 ", expCalDate, false);
assertValidDate("2004-04-29T", expCalDate, false);
assertValidDate("2004-04-29Tz", expCalDate, false);
// yyyy, mm, dd
expCalDate.set(2020, 10, 05);

assertValidDate("2020-11-05 00:00:00z", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05 00:00:00", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05 00:00", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05 00", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05 ", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05T", expCalDate, useEuropeanDateFormat);
assertValidDate("2020-11-05Tz", expCalDate, useEuropeanDateFormat);
assertValidDate("20201105", expCalDate, useEuropeanDateFormat);
assertValidDate("20201105 ", expCalDate, useEuropeanDateFormat);
if (useEuropeanDateFormat) {
assertValidDate("05/11/2020", expCalDate, useEuropeanDateFormat);
} else {
assertValidDate("11/05/2020", expCalDate, useEuropeanDateFormat);
}

//should fail
assertStringAndCalendarDoNotMatch("2004-04-29 00:00:01", expCalDate, false);
assertStringAndCalendarDoNotMatch("2020-11-05 00:00:01", expCalDate, useEuropeanDateFormat);
}


Expand Down

0 comments on commit 6ee3f84

Please sign in to comment.