I got a solution cause of activiti workflow, it is very much extendible almost all points in API. Thanks to activiti developers.
I have extended DefaultClockImpl class of activiti and override the required method to use Calendar for my purpose. Activti uses Clock to get and set Time in their entities, wherever required.
My Project is using Spring framework and did Java configuration for workflow project, So I did below changes to register my class, while doing Process engine configuration:
Override DefaultClockImpl Class
<java>public class CustomDefaultClockImpl extends DefaultClockImpl {
private static volatile Calendar CURRENT_TIME = null;
@Override
public void setCurrentTime(Date currentTime) {
Calendar time = null;
if (currentTime != null) {
time = new GregorianCalendar();
time.setTimeZone(TimeZone.getTimeZone("UTC"));
time.setTime(currentTime);
}
setCurrentCalendar(time);
}
@Override
public Calendar getCurrentCalendar() {
Calendar calendar = new GregorianCalendar();
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
return CURRENT_TIME == null ? calendar : (Calendar) CURRENT_TIME.clone();
}
}</java>
Create a Spring bean of Clock:
<java>
@Bean
public Clock clock(){
// CustomDefaultClockImpl is class which extends DefaultClockImpl
Clock clock = new CustomDefaultClockImpl();
return clock;
}
</java>
and While doing process engine configuration :
<java>
SpringProcessEngineConfiguration processEngineConfiguration =
new SpringProcessEngineConfiguration();
// Calling above method to register spring bean in activiti configuration
processEngineConfiguration.setClock(clock());
</java>
Now it will store using UTC time zone in all activiti tables, wherever date time is present in tables.