Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use property getters consistently #1357

Merged
merged 1 commit into from
Oct 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,6 @@ public static synchronized String[] initializeAppConfig(String[] args) throws Fa
Map<String, String> argsMap = AppUtil.convertCommandArgsArrayToArgMap(args);
AppConfig.setConfigurationsDir(argsMap);
LoggingUtil.initializeLog(argsMap);
AppUtil.setUseGMTForDateFieldValue(argsMap);
return AppUtil.convertCommandArgsMapToArgsArray(argsMap);
}

Expand Down
16 changes: 0 additions & 16 deletions src/main/java/com/salesforce/dataloader/util/AppUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,26 +239,10 @@ public static void extractDirFromJar(String extractionPrefix, String destDirName
public static APP_RUN_MODE getAppRunMode() {
return appRunMode;
}

public static void setUseGMTForDateFieldValue(Map<String, String> argMap) {
if (argMap.containsKey(AppConfig.PROP_GMT_FOR_DATE_FIELD_VALUE)) {
if ("true".equalsIgnoreCase(argMap.get(AppConfig.PROP_GMT_FOR_DATE_FIELD_VALUE))) {
useGMTForDateFieldValue = true;
}
}
}

public static void setUseGMTForDateFieldValue(boolean val) {
useGMTForDateFieldValue = val;
}

public static boolean isContentSObject(String sObjectName) {
return CONTENT_SOBJECT_LIST.contains(sObjectName.toLowerCase());
}
private static boolean useGMTForDateFieldValue;
public static boolean isUseGMTForDateFieldValue() {
return useGMTForDateFieldValue;
}

public static void showBanner() {
System.out.println(Messages.getMessage(AppUtil.class, "banner", DATALOADER_SHORT_VERSION, MIN_JAVA_VERSION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.GregorianCalendar;
import java.util.TimeZone;

import com.salesforce.dataloader.config.AppConfig;
import com.salesforce.dataloader.util.DLLogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -65,7 +66,8 @@ public void setTimeInMillis(long specifiedTimeInMilliSeconds) {
Calendar cal = Calendar.getInstance(myTimeZone);
cal.setTimeInMillis(specifiedTimeInMilliSeconds);

if (!AppUtil.isUseGMTForDateFieldValue() && myTimeZone != null) {
if (!AppConfig.getCurrentConfig().getBoolean(AppConfig.PROP_GMT_FOR_DATE_FIELD_VALUE)
&& myTimeZone != null) {
// Set hour, minute, second, and millisec to 0 (12:00AM) as it is date-only value
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
Expand All @@ -83,7 +85,7 @@ public void setTimeInMillis(long specifiedTimeInMilliSeconds) {
}

public static DateOnlyCalendar getInstance(TimeZone timeZone) {
if (AppUtil.isUseGMTForDateFieldValue()) {
if (AppConfig.getCurrentConfig().getBoolean(AppConfig.PROP_GMT_FOR_DATE_FIELD_VALUE)) {
timeZone = GMT_TZ;
}
return new DateOnlyCalendar(timeZone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.junit.Ignore;
import org.junit.Test;

import com.salesforce.dataloader.ConfigTestBase;
import com.salesforce.dataloader.config.AppConfig;
import com.salesforce.dataloader.util.AppUtil;

import java.util.Calendar;
Expand All @@ -41,7 +43,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

public class DateConverterTest {
public class DateConverterTest extends ConfigTestBase {

private static final TimeZone TZ = TimeZone.getTimeZone("GMT");

Expand Down Expand Up @@ -678,7 +680,7 @@ public void testUserSpecifiedTimeZoneIsUsed() throws Exception {
assertEquals(6, result.get(Calendar.MONTH) + 1);
assertEquals(22, result.get(Calendar.DAY_OF_MONTH));

AppUtil.setUseGMTForDateFieldValue(true);
this.getController().getAppConfig().setValue(AppConfig.PROP_GMT_FOR_DATE_FIELD_VALUE, true);
AsianTZDateOnlyConverter = new DateOnlyConverter(TimeZone.getTimeZone("Asia/Tokyo"), false);
USTZDateOnlyConverter = new DateOnlyConverter(TimeZone.getTimeZone("America/Los_Angeles"), false);
result = (Calendar) USTZDateOnlyConverter.convert(null, "6/22/2012");
Expand Down Expand Up @@ -716,7 +718,7 @@ public void testUserSpecifiedTimeZoneIsUsed() throws Exception {
assertEquals(7, result.get(Calendar.DAY_OF_MONTH));
assertEquals(TimeZone.getTimeZone("GMT"), result.getTimeZone());

AppUtil.setUseGMTForDateFieldValue(false);
this.getController().getAppConfig().setValue(AppConfig.PROP_GMT_FOR_DATE_FIELD_VALUE, false);
AsianTZDateOnlyConverter = new DateOnlyConverter(TimeZone.getTimeZone("Asia/Tokyo"), false);
USTZDateOnlyConverter = new DateOnlyConverter(TimeZone.getTimeZone("America/Los_Angeles"), false);

Expand Down
Loading