1

I am writing an application in which I have to capture the current date time in UTC and it to the Header of an image file.

I am using Joda date-time. Now the requirement is to get the current date time in UTC and convert it to byte byte/byte array so that it can be stored as the hexadecimal values in header of image file.

What I have tried so far

DateTime date = new DateTime().withZone(DateTimeZone.UTC).
                withChronology(ISOChronology.getInstanceUTC());

It is giving me this output:

2013-06-07T09:25:51.630Z

I dont know why there is T and z there in output.

Now I have to convert it to bytes/bytes array. But I am not getting how to do that.

Any Help?

EDIT: As per the standard I am following they have given an example of result after converion

December 15,2005 at 17:35:19.000 ==> 07D5 0C 0F 11 23 13 0000Hex

4

1 回答 1

1

DateTime date = new DateTime().withZone(DateTimeZone.UTC). withChronology(ISOChronology.getInstanceUTC());

If all you want is UTC you can use plain

long time = System.currentTimeMillis();

BTW, all computers actually use GMT rather than supporting UTC. e.g. no leap seconds.

I don't know why there is T and z there in output.

ISO 8601 standard.

Now I have to convert it to bytes/bytes array.

There are many different ways to do this. Can you say how you need the translation to be performed?

As per the standard I am following they have given an example of result after converion December 15,2005 at 17:35:19.000 ==> 07D5 0C 0F 11 23 13 0000Hex

Which standard you referring to?

If 07D5 0C 0F 11 23 13 0000 was the time in milli-seconds you would be in the year 1.1 trillion.

于 2013-06-07T10:00:01.547 回答