aspose file tools*
The moose likes Java in General and the fly likes Convert date time to file date time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convert date time to file date time" Watch "Convert date time to file date time" New topic
Author

Convert date time to file date time

sam patel
Ranch Hand

Joined: Jun 13, 2002
Posts: 103
Hi,
I have standard delphi function which conver datetime to filedatetime here is the description
function DateTimeToFileDate(DateTime: TDateTime): Integer;
Description
Use DateTimeToFileDate to convert a TDateTime value, which is the representation of date-and-time values used by the VCL, to a DOS date-and-time value.
For example, use DateTimeToFileDate to convert a TDateTime value to a
format that can be used as the Age parameter of FileSetDate. You may
also need to use DateTimeToFileDate to convert a TDateTime so that it
is compatible with the Time field of the TSearchRec record used by the FindFirst
and FindNext functions.
Lo returns the low-order Byte of the argument X as an unsigned value. X is an expression of type Integer.
Use Hi to obtain the high-order byte of an expression of type Word or Integer.
Note: Hi treats Integer as a 16-bit value, even if it is 32-bit.
This is the delphi code that convert the date
year=2003
month=5
day=28
sec=57
min=45
hr=13
msec=107

LongRec(Result).Lo := (Sec shr 1) or (Min shl 5) or (Hour shl 11);
LongRec(Result).Hi := Day or (Month shl 5) or ((Year - 1980) shl 9);

output Result is --> 784100796
Any help will be highly appreciated.
Thanks.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Sounds like you have a good handle on the requirements. If you look what is going on, you break the date into it's field elements. A good canidate for this portion would be Calendar. Then these values are shifted by the amounts lists, the results ored together and the High shifted and ored to the low.
I took a quick stab at this and here is the code I came up with:

To better understand bit operations in Java, Read Cat and Mouse Game with Bits


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert date time to file date time
 
Similar Threads
An override method problem......
need to set xml attribute in order
having problem with a stored procedure used called by a DAO
Convert String to Date
Java - Date conversion to milliseconds problem