MATLAB: Change datetime display format

datetimeformatMATLABsimulinkutcleapseconds

I have a julian date that I convert to a MATLAB datetime variable using:
tj = 2.456870501842000e+06;
mtime = datetime(tj,'ConvertFrom','juliandate','TimeZone','UTCLeapSeconds')
This creates the datetime variable "mtime" displayed as 2014-08-01T00:02:39.149Z. I want to change the display format of mtime (for plotting purposes) to show only hour:minute,
mtime.Format = 'HH:mm';
But I get this error:
The date format for UTCLeapSeconds datetimes must be 'uuuu-MM-dd'T'HH:mm:ss.SSS'Z''.
So is it not possible to change the display format of a datetime variable?

Best Answer

It is possible. It just takes some coding gymnastics:
tj = 2.456870501842000e+06;
mtime = datetime(tj,'ConvertFrom','juliandate','TimeZone','UTCLeapSeconds', 'Format','uuuu-MM-dd''T''HH:mm:ss.SSS''Z''')
ltime = mtime;
ltime.TimeZone = 'local';
ltime.Format = 'HH:mm'
producing:
ltime =
datetime
18:02
Set ‘TimeZone’ to be whatever you want it to be.