Delphi Programming

and software in general.

Tuesday, September 30, 2008

Swindell: Native code remains the core foundation of application development

Michael Swindell writes: "... Native code remains the core foundation for desktop, client/server, and workstation application development. ISVs and Micro ISVs rely on native code to deliver high-performance packaged software, and the ubiquity of multicore architectures enables programmers with abilities in native languages like C++ and Delphi to drive application development in high-growth industries like healthcare, financial markets, and services and telecommunications. ..."

Full article here: http://www.ddj.com/architect/210604499

It's good to be a Delphi developer.

Edit: I guess this is an infomercial :P - Well, I bought it :)

Wednesday, September 10, 2008

Snippet: Convert Java time to TDateTime

I am currently working on an application that need to extract content from a Java Web Service using a SOAP interface. The interface delivers all timestamps as Java timestamps (64-bit integer - UTC time in milliseconds before or after the start of January 1, 1970), so I need to convert them to TDateTime for further processing in the Delphi code.

First, I convert it to a Windows filesystem time - which is similar to the Javatime, except from the start time offset and the time resolution. Next, I convert the filetime to Windows UTC time, and adjust for the timezone - simplified to just use the default - ie current local timezone. The final step is to convert the system time constant to a TDateTime.

The whole thing is done with blatant disregard of the tradition of checking return values from the two system calls. The less optimistic of you may choose to check for return values equaling zero to indicate an error.


uses
Windows, SysUtils; // Time functions

function JavaTimeToDateTime(javatime:Int64):TDateTime;
// java time -> Win32 file time -> UTC time
// adjust to active time zone -> TDateTime
var
UTCTime, LocalTime: TSystemTime;
begin
FileTimeToSystemTime(TFileTime(Int64(javatime + 11644473600000) * 10000), UTCTime);
SystemTimeToTzSpecificLocalTime(nil, UTCTime, LocalTime);
Result := SystemTimeToDateTime(LocalTime);
end;
FYI: 11644473600000 * 10000 = 1 Jan 1970 in Windows File Time

Importing Delphi from UK to Norway

After checking with a UK based software reseller, they confirmed that they can sell licenses to Norway. Since Norway is not a member of EU, they will not charge the EU VAT rate.

After checking with the Customs Authorities in Norway, they confirmed that there is no Norwegian import tax on software.

If the software delivered on physical media,you have to pay 25% VAT to the Customs Authorities with the import declaration.

If the software is digitally delivered, the Customs Authorities don't require you to pay them the 25% VAT, although if you are required to register the cost in your balance sheets, you will need to clarify with your accountant/auditor and/or the regional tax office on how it should be registered.

For a hobbyist, that means you effectively get the software at net cost from the reseller and at the same rate as the rest of the world.

Although this solves the problem with the inflated price of Delphi on the Nordic CodeGear web shop for the consumer - I can't help but to ponder what kind of problem this pose for the local resellers. They would have to be able to offer some seriously good support to compensate for the inflated price they are required to charge.