• 周五. 12月 2nd, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

HEX Date creation – Java From 5gw.org

[db:作者]

4月 10, 2022

xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en”>
HEX Date creation – Java
/**
* Bytes CSS
* Style: ‘bytes.answers’; Style ID: 18
*/
@import url(“/clientscript/vbulletin_css/style-12635a82-00018.css”);

 
 
470,371 Members | 1,560 Online

HEX Date creation

Jim
Can someone tell me how the following date and time is created to the
Hex value (also shown below)?

Tuesday, July 08, 2003 10:56:38 AM

hex:00,90,a6,7b,66,45,c3,01

I need to be able to create the hex value for any date, but am not
sure how to break it down. Serail Parts?

Jul 17 ’05
#1

1 10317


(adsbygoogle = window.adsbygoogle || []).push({});

ja************@teldta.com (Jim) wrote in message news:<e5**************************@posting.google. com>…

Can someone tell me how the following date and time is created to the
Hex value (also shown below)?

Tuesday, July 08, 2003 10:56:38 AM

hex:00,90,a6,7b,66,45,c3,01

I need to be able to create the hex value for any date, but am not
sure how to break it down. Serail Parts?

Timestamps can be expressed as seconds or milliseconds since a
given epoch. If you check out java.util.Date you’ll see it can
‘convert’ dates to and from this type of format, using a ‘long’.

There are eight hex numbers above, each representing a byte.
The first thing to try is to see if these bytes represent a
long, by forming the digits into a String (minus the commas)
and converting said string to a Date object by parsing the
value using base 16.

String hexString="0090a67b6645c301"; // Woundn’t be hardcoded!
Date d = new Date(Long.parseLong(hexString,16));

Obviously this will only work if the value represented by the
hex string is scaled the same as Java expects (ie: measures
milliseconds, not seconds) and uses the same epoch. If not,
you’ll have to tinker with the long value to get it in the same
scale, and/or adjust the epoch. (Java uses Jan 1st 1970 00:00:00
GMT — other languages/API’s use 1900 not 1970!)
-FISH- ><>

Jul 17 ’05
#2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics


5 posts

views

Thread by [ EuGeNe ] |
last post: by


2 posts

views

Thread by David Fickbohm |
last post: by


4 posts

views

Thread by wil |
last post: by


3 posts

views

Thread by Steven Blair |
last post: by


6 posts

views

Thread by KoRnDragon |
last post: by


3 posts

views

Thread by tkpmep |
last post: by


reply

views

Thread by cosinus |
last post: by

By using this site, you agree to our Privacy Policy and Terms of Use.


(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-90111-7’, ‘bytes.com’);
ga(‘send’, ‘pageview’);

loadBytesTracking()

//0){location.replace(‘https://bytes.com/showthread.php?p=’+cpostno);};} }

if(typeof window.orig_onload == “function”) window.orig_onload();
}

//]]>

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注