I am creating AWS instances programmatically using AWS Java API. This entire process is developed as an web application.
Now the question is, after successfully purchasing an EC2 instance, how can I display the price details of that particular customer's instance cost?
This is not a capability exposed by the AWS EC2 API.
The pricing of instances is a back-office billing function, not a function of the real-time EC2 operational infrastructure, since -- among other reasons -- there are tiered volume discounts for large customers ... and the rating of reserved instances is not related to particular instances but is actually determined by how many instances you are running, correlated with the number of matching instances purchased. (Whether a particular instance is billed as reserved or not can vary throughout the lifetime of the instance, if others are also running)... and spot instances are billed based on historical prices as they stood at the beginning of the spot instance's operational hour, each hour, not in fractional hours, even though the spot market price can fluctuate several times per hour.
The only known mechanism is the unofficial, unsupported, undocumented hack mentioned in the other question you referenced. If you go that route, implementing it should be a pretty trivial exercise in Java or any other language... but the pricing you would be able to display would be an approximation.