I have this date object which when is printed to the console is "Mar 24 22:31:00 EET 2023", now I want to convert this date to the following format : yyyy-MM-dd'T'HH:mm:ssXXX what I have tried is the following:
Date currentTimeStampInUtc =//the utc date retrieved
final DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
String currentTimeFormattedWithTimezone = format.format(currentTimeStampInUtc);
but I get an exception "Cannot format given Object as a Date". Any suggestions how to forma the Date object to the given format?