Question

I ma trying to understand following paragraph:

start_time: This 40-bit field contains the start time of the event in Universal Time, Co-ordinated (UTC) and Modified Julian Date (MJD). This field is coded as 16 bits giving the 16 LSBs of MJD followed by 24 bits coded as 6 digits in 4-bit Binary Coded Decimal (BCD). If the start time is undefined (e.g. for an event in a NVOD reference service) all bits of the field are set to "1".

Example 1: 93/10/13 12:45:00 is coded as "0xC079124500".

I want to convert 40-bit to date and time in java without using third party library.

Please help me on this.

Was it helpful?

Solution

Ok, I got it working.

From 40 bits, 16 msb bits represents MJD. Remaining 24 bits represent time in BCD coded as HHMMSS.

For example 0xC079 in question represents MJD, that is 49273 in decimal.

To convert MJD to date, convert MJD in decimal (above converted to 49273), then:

To find Y, M, D from MJD:

Y' = int [(MJD - 15078.2) / 365.25]
M' = int { [MJD - 14956.1 - int (Y' * 365.25) ] / 30.6001 }
D = MJD - 14956 - int (Y' * 365.25) - int (M' * 30.6001 )

If M' = 14 or M' = 15, then K = 1; else K = 0

Y = Y' + K

M = M' - 1 - K * 12

Where

MJD Modified Julian Date

Y Year from 1900 (e.g. for 2003, Y = 103)

M Month from January (= 1) to December (= 12)

D Day of month from 1 to 31

K ,M', Y' Intermediate variables

* Multiplication

int Integer part, ignoring remainder

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top