As commented, trying to access internally defined fields that were intentionally hidden from outside calling programmers would be unwise.
As commented, you seem to have an XY Problem. I'll take a stab at what you might need.
You are using terrible date-time classes that were years ago supplanted by the modern java.time classes defined in JSR 310. Never use Calendar
, Date
, etc.
You claim to have a call to a method requiring a java.util.Date
object that represents the current moment as seen in UTC, that is, with an offset of zero hours-minutes-seconds. To capture the current moment, use Instant
class.
Instant now = Instant.now() ; // Current moment as seen with an offset of zero.
I suggest you educate the author of that called method about how Date
has been replaced by Instant
.
Until they update their API, you can easily convert between legacy and modern classes by calling conversion methods added to the old classes.
java.util.Date d = Date.from( now ) ;
request.setGatewayEndTime( d );
As for the BaseCalendar.Date
field, if your goal is to get a string in ISO 8601 format similar to the string you show in your screenshot which is nearly in standard format but omits the COLON from between the hours and minutes of the offset, then simply call Instant#toSting
. The java.time classes use ISO 8601 format by default when parsing/generating strings.
String output = now.toString() ; // Generate text in standard ISO 8601 format.
Your screenshot uses another offset other than zero. If you wish to see a moment with the offset of a particular time zone, apply a ZoneID
object to produce a ZonedDateTime
object.
ZoneId z = ZoneId.of( "America/La_Paz" ) ;
ZonedDateTime zdt = now.atZone( z ) ;
Produce text in standard ISO 8601 format that has been wisely extended to include the name of the time zone in square brackets.
String output = zdt.toString() ;