Salesforce Query Returning Wrong Date

Asked

Viewed 55 times

0

In Salesforce when I run the following query SELECT Data_de_Nascimento__c FROM Account WHERE id = '0013K00000ABC' he returns me 1999-05-29

In Java, after I set up the integration, I run this algorithm

QueryResult resultado = salesforce.query("SELECT Data_de_Nascimento__c FROM Account WHERE id = '0013K00000ABC'");

SObject[] registros = resultado.getRecords();

for (Object hospedagemSalesforce : registros) {
    Account account = (Account) hospedagemSalesforce;
    int dia = account.getData_de_Nascimento__c().get(Calendar.DAY_OF_MONTH);
    int mes = account.getData_de_Nascimento__c().get(Calendar.MONTH) + 1;
    int ano = account.getData_de_Nascimento__c().get(Calendar.YEAR);

    System.out.println(ano + "-" + mes + "-" + dia);
}

the exit me 1999-5-28

The query always returns me 1 day less, someone knows what it might have caused?

1 answer

1

Probably the Java and database Timezone are different.

If using Mysql, to check the Timezone:

select @@session.time_zone

Then you can run the application by setting the Timezone. For example:

-Duser.timezone=Europe/Sofia
  • Actually I’m not using Mysql, I’m using SOQL (Salesforce database), I’ve already found that same answer your other questions but did not solve... even so thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.