This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Convert Calendar to java.sql.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Convert Calendar to java.sql.Date" Watch "Convert Calendar to java.sql.Date" New topic

Convert Calendar to java.sql.Date

Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hi guys,

In my project I am having a situation like this.

I have the Calendar object.

I have to convert it into java.sql.Date object.

Can you give the code for that.

Thanks for your comments.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Here is a big hint.
See the java.sql.Date constructor ? It takes an long as parameter, representing the time in millisecs.
Which method from Calendar can return the time in millisecs ?

[My Blog]
All roads lead to JavaRanch
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Thanks Satou,

I got it
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Convert Calendar to java.sql.Date
It's not a secret anymore!