简体   繁体   中英

Oracle Data can not set Time on gregorian calendar

I create java method which I load to oracle database and run it from plsql code.

public static int getSomethink(Integer multiplicity, DATE startDate);

This method takes oracle.sql.DATE startDate .

When I want to:

GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(startDate);

I have an error which say method setTime(Date) accept normal Date , not oracle.sql.DATE . So here is my questions:

How to create conversion between java.util.Date and oracle.sql.DATE ? Do you have any others ideas which can solve this issue?

You could simply call dateValue() on startDate to convert internal Oracle Date to a Java Date.

Something like:

Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate.dateValue());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM