0

Code to extract the time from a version 1 UUID

asked 2009-05-26 12:53:15 +0800

kingsz1 gravatar image kingsz1
81 1 3

Hello, I found a funy page:
http://www.famkruithof.net/uuid/uuidgen?typeReq=-1
It will extract the time stamp from a given version 1 UUID.
Any idea how to do this in java code?
Thanks a lot.

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-05-26 15:42:34 +0800

YamilBracho gravatar image YamilBracho
1722 2

check http://www.ietf.org/rfc/rfc4122.txt

link publish delete flag offensive edit

answered 2009-05-27 03:11:27 +0800

kingsz1 gravatar image kingsz1
81 1 3

updated 2009-05-27 03:13:28 +0800

Hi, thanks. For example a UUID: ed37f5f0-4a6a-11de-8a39-0800200c9a66

Fro rfc4122:
4.1.4. Timestamp

The timestamp is a 60-bit value. For UUID version 1, this is
represented by Coordinated Universal Time (UTC) as a count of 100-
nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of
Gregorian reform to the Christian calendar).

For systems that do not have UTC available, but do have the local
time, they may use that instead of UTC, as long as they do so
consistently throughout the system. However, this is not recommended
since generating the UTC from local time only needs a time zone
offset.

I want to know how to convert the timestamp portion (60 bits from left, such as ed37f5f0-4a6a-1de )to a clock time, something like this:

The UUID ed37f5f0-4a6a-11de-8a39-0800200c9a66 contains a timestamp taken at
Wednesday, May 27, 2009 3:03:17 AM GMT

I am new in java and learning zk. Please help in detail, if possible.

link publish delete flag offensive edit

answered 2009-05-27 09:33:46 +0800

kindalu gravatar image kindalu
255

It's wikipedia.

Conceptually, the original (version 1) generation scheme for UUIDs was to concatenate the UUID version with the MAC address of the computer that is generating the UUID, and with the number of 100-nanosecond intervals since the adoption of the Gregorian calendar in the West. In practice, the actual algorithm is more complicated. This scheme has been criticized in that it is not sufficiently 'opaque'; it reveals both the identity of the computer that generated the UUID and the time at which it did so.

It seems if you don't provide the Mac address cannot extract it, or even provide it ...still can not reverse the operation....

PS: I'm not sure.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-05-26 12:53:15 +0800

Seen: 210 times

Last updated: May 27 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More