AbsoluteDate to Day of Year

Hello,
I’d like to convert an AbsoluteDate (ORbit Extrapolation KIT 11.2 API) object to a string in format:

DDDHHMM

where,
DDD is the day of year (eg. 300 for 26-oct-2020)
HH is the hour (24-hours) (eg. 13 for 1 PM)
MM is the minute (eg. 05)

How can it be accomplished?
Can I use Orekit or should I convert it .toString() and then use specific language formatting?

Thank you,
Alfredo

You can use something along these lines:

DateTimeComponents components = date.getComponents(utc);
System.out.format(Locale.US, "%03d%02d%02d",
                  components.getDate().getDayOfYear(),
                  components.getTime().getHour(),
                  components.getTime().getMinute());
1 Like

Thanks @luc, that answered my question!
If anyone else needs it, I leave here my Python code, where state is a SpacecraftState:

components = state.getDate().getComponents(TimeScalesFactory.getUTC())
DDDHHMM = '{:03d}{:02d}{:02d}'.format(components.getDate().getDayOfYear(),components.getTime().getHour(),components.getTime().getMinute())

Thank you.
Kind Regards,
Alfredo

1 Like