function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ZAPEXZAPEX 

java.util.GregorianCalendar Flow error

I am using Flow to run an API call to an external system that in turn return a record structure, One of the records fields is a datetime field type. When I try to access the record datetime field in a screen element (or any other element) I am getting  the below error
 
class java.util.GregorianCalendar cannot be cast to class moduleapi.interaction.DateTime (java.util.GregorianCalendar is in module java.base of loader 'bootstrap'; moduleapi.interaction.DateTime is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4ee37ca3)

below is the Apex Action I use. The Action save its output into an account record variable and then after if I try to access the datetime__c field I get the class java.util.GregorianCalendar error I reported above.Why? if I use date instead of datetime it works. If I initiate the datetime__c like this it works out.acc = [select name, datetime__c from Account where id ='0014J000004uVIUQA2'];

driving me nuts.

global class datetime_issue {

@InvocableMethod(label = 'datetime_issue')
global static list<outputCls> getAccounts() {

outputCls out = new outputCls();
out.acc = new account();
out.acc.datetime__c = system.now();
out.acc.name = 'datetime issue';


return new list<outputCls>{out};
}

global class outputCls {

@InvocableVariable
public account acc;
}
}
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

Can you please check the below document which will help you in resolving the error:

https://community.talend.com/t5/Design-and-Development/Calendar-cannot-be-resolved-to-a-type/td-p/50598

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
ZAPEXZAPEX
Shirisha thanks but it did not help. 

to iterate/clarify,  the issue occurs in flow when I try to access a custom datetime field in a record variable that is set using invocable variable. 
for example

 global class outputCls { 
        @InvocableVariable public account acc; //<-- acc.datetime__c does not work
        @InvocableVariable public account acc; //<-- acc.createddate works
        @InvocableVariable public datetime dt; //<-- works
}

  
ShirishaShirisha (Salesforce Developers) 
Hi Zapex,

Greetings!

Please be informed that,this issue has been identified as bug from salesforce product team and they have created the bug on this scenario.Unfortunately,we do not have the public facing document/known issue but it was identified.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
ZAPEXZAPEX
Thanks for your reply. Have issues to connect but not doubt it is the best answer I got.