Casting oracle.jbo.domain.Date to java.util.Date and maintain more than day
oracle.jbo.domain.Date now = getOADBTransaction().getCurrentDBDate();
java.sql.Date currentDate = now.dateValue();
will truncate the hour, minute, second etc.
How can I avoid this?
No luck with that either.
oracle.jbo.domain.Date now = getOADBTransaction().getCurrentDBDate();
and then
java.sql.Timestamp currentDate = now.dateValue(); won't compile - gives class mis-match.
java.sql.Timestamp currentDate = now.getTime(); won't compile - getTime doesn't exist even though code insight suggests it.
java.sql.Timestamp currentDate = new java.sql.Timestamp(now.dateValue()); won't compile because no such constructor for Timestamp exists.
Similar Messages
-
Summary:
JDK 1.7.0_09 and wsimport and xjc that comes with it.
Global JAXB binding to map xs:date to java.util.Date
I have the following external bindings file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
elementFormDefault="qualified" attributeFormDefault="unqualified"
jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<xjc:serializable />
<jaxb:javaType name="java.util.Date" xmlType="xs:date" parseMethod="au.com.xxx.jaxb.DateAdapter.parseDate" printMethod="au.com.xxx.jaxb.DateAdapter.printDate" />
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
</xs:schema>The au.com.xxx.jaxb.DateAdapter code is as follows:
package au.com.xxx.jaxb;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.bind.DatatypeConverter;
public class DateAdapter {
public static Date parseDate(String s) {
return DatatypeConverter.parseDate(s).getTime();
public static String printDate(Date dt) {
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
return DatatypeConverter.printDate(cal);
}When I run the following wsimport from the command line, I get:
salvojo@AUD20901BL /cygdrive/c/workspace/JSF/insurance
$ /cygdrive/c/java/jdk1.7.0_09/x64/bin/wsimport -keep -s gen-src -b external/wsdl/jaxb-bindings.xml -wsdllocation /wsdl/Member.wsdl -d WebContent/WEB-INF/classes external/wsdl/Member.wsdl
parsing WSDL...
Generating code...
Compiling code...
C:\workspace\JSF\insurance\gen-src\org\w3\_2001\xmlschema\Adapter1.java:13: error: package au.com.xxx.jaxb does not exist
return (au.com.xxx.jaxb.DateAdapter.parseDate(value));
^
C:\workspace\JSF\insurance\gen-src\org\w3\_2001\xmlschema\Adapter1.java:17: error: package au.com.xxx.jaxb does not exist
return (au.com.xxx.jaxb.DateAdapter.printDate(value));
^
2 errors
compilation failed, errors should have been reportedWhich means that wsimport or xjc needs to know the classpath to find au.com.xxx.jaxb.DateAdapter.
But how do I pass the classpath from wsimport to the JAXB compiler ?
There is the -B option in wsimport, but I could not get it to work.
If I read it correctly, I should be able to pass the -classpath option to the JAXB compiler from wsimport via -B.
I tried:
salvojo@AUD20901BL /cygdrive/c/workspace/JSF/insurance
$ /cygdrive/c/java/jdk1.7.0_09/x64/bin/wsimport -keep -s gen-src -B"-classpath WebContent/WEB-INF/classes" -b external/wsdl/jaxb-bindings.xml -wsdllocation /wsdl/Member.wsdl -d WebContent/WEB-INF/classes external/wsdl/Member.wsdl
no such JAXB option: -classpath WebContent/WEB-INF/classes
Usage: wsimport [options] <WSDL_URI>
where [options] include:
-b <path> specify jaxws/jaxb binding files or additional schemas
(Each <path> must have its own -b)
-B<jaxbOption> Pass this option to JAXB schema compiler
-catalog <file> specify catalog file to resolve external entity references
supports TR9401, XCatalog, and OASIS XML Catalog format.
-d <directory> specify where to place generated output files
<...snipped...>... where WebContent/WEB-INF/classes is the classpath where au.com.xxx.jaxb.DateAdapter.class could be found. Obviously it did not like it.
Also, why is wsimport generate org.w3._2001.xmlschema.Adapter1.java ? All it is doing is wrapping up the exact same call that I have specified in my DateAdapter. How can I tell wsimport or xjc to NOT create that extra Adapter1.java and simply directly use my DateAdapter ??create additional column of type LONG to represent date.
dateFormat is of type java.util.Date:
long newLongDate = dateFormat.getTime();
select object(b) from MyEntity b where b.MYLONGDATE > ?1 and b.MYLOGDATE <= ?2 -
Cannot find symbl method update Date(int,java.util.Date)
I get following error
cannot find symbl method update Date(int,java.util.Date) on compling class called GuestDataBean at line ( rowSet.updateDate( 4, guest.getDate() ); ).
GustBean.java. I need help on why I get it.
// JavaBean to store data for a guest in the guest book.
package com.deitel.jhtp6.jsp.beans;
import java.util.*;
public class GuestBean
private String firstName;
private String lastName;
private String email;
private Date date;
private String message;
//Constructors
public GuestBean(){
public GuestBean(String firstname, String lastname, String email,Date date,String message){
this.firstName=firstname;
this.lastName=lastName;
this.email=email;
this.date=date;
this.message=message;
// set the guest's first name
public void setFirstName( String name )
firstName = name;
} // end method setFirstName
// get the guest's first name
public String getFirstName()
return firstName;
} // end method getFirstName
// set the guest's last name
public void setLastName( String name )
lastName = name;
} // end method setLastName
// get the guest's last name
public String getLastName()
return lastName;
} // end method getLastName
// set the guest's email address
public void setEmail( String address )
email = address;
} // end method setEmail
// get the guest's email address
public String getEmail()
return email;
} // end method getEmail
public void setMessage( String mess)
message = mess;
} // end method setEmail
// get the guest's email address
public String getMessage()
return message;
} // end method getEmail
public void setDate( Date dat )
date = dat;
} // end method setEmail
// get the guest's email address
public Date getDate()
return date;
} // end method getEmail
} // end class GuestBean
GuestDataBean.java/**
* @(#)GuestDataBean.java
* @author
* @version 1.00 2008/7/18
// Class GuestDataBean makes a database connection and supports
// inserting and retrieving data from the database.
package com.deitel.jhtp6.jsp.beans;
import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;
import java.util.ArrayList;
import com.sun.rowset.CachedRowSetImpl; // CachedRowSet implementation
import java.sql.*;
public class GuestDataBean
private CachedRowSet rowSet;
// construct TitlesBean object
public GuestDataBean() throws Exception
// load the MySQL driver
Class.forName( "org.gjt.mm.mysql.Driver" );
// specify properties of CachedRowSet
rowSet = new CachedRowSetImpl();
rowSet.setUrl( "jdbc:mysql://localhost:3306/virsarmedia" );
rowSet.setUsername( "root" );
rowSet.setPassword( "" );
// obtain list of titles
rowSet.setCommand(
"SELECT firstName, lastName, email,date,message FROM guest" );
rowSet.execute();
} // end GuestDataBean constructor
// return an ArrayList of GuestBeans
public ArrayList< GuestBean > getGuestList() throws SQLException
ArrayList< GuestBean > guestList = new ArrayList< GuestBean >();
rowSet.beforeFirst(); // move cursor before the first row
// get row data
while ( rowSet.next() )
GuestBean guest = new GuestBean();
guest.setFirstName( rowSet.getString( 1 ) );
guest.setLastName( rowSet.getString( 2 ) );
guest.setEmail( rowSet.getString( 3 ) );
guest.setDate( rowSet.getDate( 4 ) );
guest.setMessage( rowSet.getString( 5 ) );
guestList.add( guest );
} // end while
return guestList;
} // end method getGuestList
// insert a guest in guestbook database
public void addGuest( GuestBean guest ) throws SQLException
rowSet.moveToInsertRow(); // move cursor to the insert row
// update the three columns of the insert row
rowSet.updateString( 1, guest.getFirstName() );
rowSet.updateString( 2, guest.getLastName() );
rowSet.updateString( 3, guest.getEmail() );
rowSet.updateDate( 4, guest.getDate() );
rowSet.updateString( 5, guest.getMessage() );
rowSet.insertRow(); // insert row to rowSet
rowSet.moveToCurrentRow(); // move cursor to the current row
rowSet.commit(); // propagate changes to database
} // end method addGuest
} // end class GuestDataBeanThis isn't a JSP question, it better belongs in the JavaProgramming, or JDBC forums.
But the problem is because the updateDate method uses a java.sql.Date object and you are giving it a java.util.Date object. You have to convert from java.util.Date to java.sql.Date. See: [the api for java.sql.Date|http://java.sun.com/javase/6/docs/api/java/sql/Date.html] .
Edited by: stevejluke on Jul 21, 2008 5:43 PM -
Convert java.sql.Date to java.util.Date
How do i convert a java.sql.Date to java.util.Date ?
SimpleDateFormat formatter = new SimpleDateFormat ("dd/MM/yy HH:mm");
Date received=myresultset.getDate(1);
String utildate = formatter.format(received);
<%=utildate%>
Result : doesn't keep the HH:mm format
14/03/04 00:00
Ideas ?There is simple way to do this job...
java.util.Date utilDate = new java.util.Date();
java.sql.Data sqlDate = new java.sql.Date(utilDate.getTime())
Enjoy Coding ! ! ! ! ! -
All I want to do is create a java.sql.Date subclass which has the Date(String) constructor, some checks for values and a few other additional methods and that avoids deprecation warnings/errors.
I am trying to write a wrapper for the java.sql.Date class that would allow a user to create a Date object using the methods:
Date date1 = new Date(2003, 10, 7);ORDate date2 = new Date("2003-10-07");I am creating classes that mimic MySQL (and eventually other databases) column types in order to allow for data checking since MySQL does not force checks or throw errors as, say, Oracle can be set up to do. All the types EXCEPT the Date, Datetime, Timestamp and Time types for MySQL map nicely to and from java.sql.* objects through wrappers of one sort or another.
Unfortunately, java.sql.Date, java.sql.Timestamp, java.sql.Time are not so friendly and very confusing.
One of my problems is that new java.sql.Date(int,int,int); and new java.util.Date(int,int,int); are both deprecated, so if I use them, I get deprecation warnings (errors) on compile.
Example:
public class Date extends java.sql.Date implements RangedColumn {
public static final String RANGE = "FROM '1000-01-01' to '8099-12-31'";
public static final String TYPE = "DATE";
* Minimum date allowed by <strong>MySQL</strong>. NOTE: This is a MySQL
* limitation. Java allows dates from '0000-01-01' while MySQL only supports
* dates from '1000-01-01'.
public static final Date MIN_DATE = new Date(1000 + 1900,1,1);
* Maximum date allowed by <strong>Java</strong>. NOTE: This is a Java limitation, not a MySQL
* limitation. MySQL allows dates up to '9999-12-31' while Java only supports
* dates to '8099-12-31'.
public static final Date MAX_DATE = new Date(8099 + 1900,12,31);
protected int _precision = 0;
private java.sql.Date _date = null;
public Date(int year, int month, int date) {
// Deprecated, so I get deprecation warnings from the next line:
super(year,month,date);
if(! isWithinRange(this))
throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
public Date(String s) {
super(0l);
// Start Cut-and-paste from java.sql.Date.valueOf(String s)
int year;
int month;
int day;
int firstDash;
int secondDash;
if (s == null) throw new java.lang.IllegalArgumentException();
firstDash = s.indexOf('-');
secondDash = s.indexOf('-', firstDash+1);
if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
day = Integer.parseInt(s.substring(secondDash+1));
} else {
throw new java.lang.IllegalArgumentException();
// End Cut-and-paste from java.sql.Date.valueOf(String s)
// Next three lines are deprecated, causing warnings.
this.setYear(year);
this.setMonth(month);
this.setDate(day);
if(! isWithinRange(this))
throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
public static boolean isWithinRange(Date date) {
if(date.before(MIN_DATE))
return false;
if(date.after(MAX_DATE))
return false;
return true;
public String getRange() { return RANGE; }
public int getPrecision() { return _precision; }
public String getType() { return TYPE; }
}This works well, but it's deprecated. I don't see how I can use a java.util.Calendar object in stead without either essentially re-writing java.sql.Date almost entirely or losing the ability to be able to use java.sql.PreparedStatement.get[set]Date(int pos, java.sql.Date date);
So at this point, I am at a loss.
The deprecation documentation for constructor new Date(int,int,int)says "instead use the constructor Date(long date)", which I can't do unless I do a bunch of expensive String -> [Calendar/Date] -> Milliseconds conversions, and then I can't use "super()", so I'm back to re-writing the class again.
I can't use setters like java.sql.Date.setYear(int) or java.util.setMonth(int) because they are deprecated too: "replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date)". Well GREAT, I can't go from a Date object to a Calendar object, so how am I supposed to use the "Calendar.set(...)" method!?!? From where I'm sitting, this whole Date deprecation thing seems like a step backward not forward, especially in the java.sql.* realm.
To prove my point, the non-deprecated method java.sql.Date.valueOf(String) USES the DEPRECATED constructor java.util.Date(int,int,int).
So, how do I create a java.sql.Date subclass which has the Date(String) constructor that avoids deprecation warnings/errors?
That's all I really want.
HELP!I appreciate your help, but what I was hoping to accomplish was to have two constructors for my java.sql.Date subclass, one that took (int,int,int) and one that took ("yyyy-MM-dd"). From what I gather from your answers, you don't think it's possible. I would have to have a static instantiator method like:public static java.sql.Date createDate (int year, int month, int date) { ... } OR public static java.sql.Date createDate (String dateString) { ... }Is that correct?
If it is, I have to go back to the drawing board since it breaks my constructor paradigm for all of my 20 or so other MySQL column objects and, well, that's not acceptable, so I might just keep my deprecations for now.
-G -
How To Add Days into a Date from java.util.Date class
I have a problem when i wants to add 2 or days into a
date object geting by java.util.Date class. so please help me resolve this issue?
for e.g i have a date object having 30/06/2001,
by adding 2 days i want 02/07/2001 date object ?
Code
public class test2
public static void main(String args[])
java.util.Date postDate = new java.util.Date();
myNewDate = postDate /* ?*/;
Here i want to add 2 date into postDateUse Calendar...
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY, 2); // I'm not sure about that "DAY" -
I can't cast java.util.Date to oracle.jbo.domain.Date
Hi, i have a variable "pippo" type java.util.Date formatted like (dd-MM-YYYY hh:mm:ss)
and I want insert in my Database where the field is Date type(oracle.jbo.domain.Date)
in the same format(dd-MM-YYYY hh:mm:ss).
I try to convert "pippo" but the result is formatted(dd-MM-YYYY hh:mm:ss).
Thank's a lot yours time and i'm very sorry for my easy english
Bye LucaHere is what i have seen that works , but does not preserve milliseconds. Does anyone have other solution? Using dateValue() looses hours, mins and seconds.
public oracle.jbo.domain.Date toJboDate(java.util.Date pJavaDate)
return new oracle.jbo.domain.Date(new Timestamp(pJavaDate.getTime()));
public java.util.Date toJavaDate(oracle.jbo.domain.Date pJboDate)
return new Date(pJboDate.timestampValue().getTime());
Chandresh -
Oracle Timestamp and java.util.date
Greetings,
【Enviroment】
oracle 10g Express
jdbc 10.2.0.1.0 thin driver
windows Xp professinal
【problem】
I fetched a value of timestamp.
And I faced An Error that "java.sql.SQLException: Cannot set lastup_dt: incompatible types."
We define data type of lastup_dt is timestamp on Oracle.
And We define the data type of lastup_dt of javaBean is java.util.date.
And Ocurr SQLException at result = rsh.handle(rs);
How Can I avoid it?
public Object query(Connection conn, String sql, Object[] params,
ResultSetHandler rsh) throws SQLException {
PreparedStatement stmt = null;
ResultSet rs = null;
Object result = null;
try {
stmt = this.prepareStatement(conn, sql);
this.fillStatement(stmt, params);
rs = this.wrap(stmt.executeQuery());
result = rsh.handle(rs);
} catch (SQLException e) {
this.rethrow(e, sql, params);
} finally {
try {
close(rs);
} finally {
close(stmt);
return result;
Any help I appreciate it.
Thank you.As long as you have the long representation of the time you can create a new java.util.Date:
new java.util.Date(ts.getTime()) -
Oracle.jbo.domain.TimestampTZ issue
JDeveloper Version 11.1.1.5.0
I have a issue with the oracle.jbo.domain.TimestampTZ field. I have a Search screen, when I search on the oracle.jbo.domain.TimestampTZ fields select the date time for the picker, I get the following exception
JBO-26023: Custom class oracle.jbo.domain.TimestampTZ is not assignable to oracle.jbo.format.Formatter
Also, I want to know how to specify the format for oracle.jbo.domain.TimestampTZ field in the View object. NowYou could try adding one of these libraries to your project (BC4J Service Runtime, Java EE 1.5, Toplink) and then using [url http://docs.oracle.com/cd/B14099_19/web.1012/b15903/oracle/toplink/internal/platform/database/oracle/TIMESTAMPHelper.html]this
John -
Error while deploying a web service whose return type is java.util.Date
Hi
I have written a simple web service which takes in a date input (java.util.Date) and returns the same date back to the client.
public interface Ping extends Remote
* A simple method that pings the server to test the webservice.
* It sends a datetime to the server which returns the datetime.
* @param pingDateRequest A datetime sent to the server
* @returns The original datetime
public Date ping(Date pingDateRequest) throws RemoteException;
The generation of the Web service related files goes smoothly in JDeveloper 10g. The problem arises when I try to deploy this web service on the Oracle 10g (10.0.3) OC4J standalone. it gives me the following error on the OC4J console :
E:\Oracle\oc4j1003\j2ee\home\application-deployments\Sachin-TradingEngineWS-WS\
WebServices\com\sachin\tradeengine\ws\Ping_Tie.java:57: ping(java.util.Date) in com.sachin.tradeengine.ws.Ping cannot be applied to (java.util.Calendar) _result = ((com.sachin.tradeengine.ws.Ping) getTarget()).ping
(myPing_Type.getDate_1());
^
1 error
04/03/23 17:17:35 Notification ==> Application Deployer for Sachin-TradingEngineWS-WS FAILED: java.lang.InstantiationException: Error compiling :E:\Oracle\oc4j1003\j2ee\home\applications\Sachin-TradingEngineWS-WS\WebServices: Syntax error in source [ 2004-03-23T17:17:35.937GMT+05:30 ]
I read somewhere that the conversion between java to xml datatype and vice versa fails for java.util.Date, so it is better to use java.util.Calendar. When I change the code to return a java.util.Calendar then the JDeveloper prompts me the following failure:
Method Ping: the following parameter types do not have an XML Schema mapping and/or serializer specified : java.util.Calendar.
This forces me to return a String data.
I would appreciate if someone can help me out.
Thanks
Sachin Mathias
Datamatics Ltd.Hi
I got the web service working with some work around. But I am not sure it this approach would be right and good.
I started altogether afresh. I did the following step :
1. Created an Interface (Ping.java) for use in web Service as follows :
public interface Ping extends Remote{
public java.util.Date ping(java.util.Date pingDateRequest)
throws RemoteException;
2. Implemented the above interface in PingImpl.java as follows :
public class PingImpl implements Ping
public java.util.Date ping(java.util.Date pingDateRequest) throws RemoteException {
System.out.println("PingImpl: ping() return datetime = " + pingDateRequest.toString());
return pingDateRequest;
3. Compiled the above 2 java files.
4. Generated a Stateless Java Web Service with the help of JDeveloper. This time the generation was sucessful.(If I had "java.util.Calendar" in place of "java.util.Date" in the java code of the above mentioned files the web service generation would prompt me for error)
5. After the generation of Web Service, I made modification to the Ping interface and its implementing class. In both the files I replaced "java.util.Date" with "java.util.Calendar". The modified java will look as follows :
Ping.Java
=========
public interface Ping extends Remote{
public java.util.Calendar ping(java.util.Calendar pingDateRequest)
throws RemoteException;
PingImpl.Java
================
public class PingImpl implements Ping
public java.util.Calendar ping(java.util.Calendar pingDateRequest) throws RemoteException {
System.out.println("PingImpl: ping() return datetime = " + pingDateRequest.toString());
return pingDateRequest;
6. Now I recompile both the java files.
7. Withour regenerating the Web Service I deploy the Web Service on OC4j 10.0.3 from JDeveloper. This time the deployment was sucessful.(The Deployment fails if I don't follow the step 5.)
8. Now I generated a Stub from JDeveloper and accessed the stub from a client. It works fine. Here if you see the Stub code it takes java.util.Date as a parameter and returns a java.util.Date. (Mind you I am accepting a java.util.Calendar and returning the same in my Web Service interface. Step 5)
The confusing thing is the Serialization and Deserialization of Data from Client java data to Soap message and Soap message to Server java data.
From Client to SOAP :
java.util.Date to datetime
From SOAP to Server :
datetime to java.util.Calendar
From Server to SOAP :
java.util.Calendar to datetime
From SOAP to Client :
datetime to java.util.Date (I am not able to understand this part of the conversion)
Any help or inputs would be appreciated.
Thanks
Sachin Mathias -
Duration between 2 java.util.Dates
Hi,
Recently found a problem calculating duration between two dates. It has confused me as it happens only on certain dates!
Notice the duration for 28/10/07 - outputs 85 minutes. Am I missing something obvious here?
GregorianCalendar gc = new GregorianCalendar(2007,0,1);
for(int i=0; i<365; i++) {
String date = gc.get(Calendar.DATE) + "/" + (gc.get(Calendar.MONTH)+1) + "/" + gc.get(Calendar.YEAR);
String dateVal1 = date + " 00:39";
GregorianCalendar date1 = DateTime.toGregorianCalendar(dateVal1, "dd/MM/yy HH:mm");
String dateVal2 = date + " 01:04";
GregorianCalendar date2 = DateTime.toGregorianCalendar(dateVal2, "dd/MM/yy HH:mm");
System.out.println(date + " - " + DateTime.calculateDuration(date1, date2));
gc.add(Calendar.DATE, 1);
public final static GregorianCalendar toGregorianCalendar(String date, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
GregorianCalendar gc1 = new GregorianCalendar();
Date parsedTime = new Date();
try {
parsedTime = formatter.parse(date);
} catch (ParseException ex) {
ex.printStackTrace();
return null;
gc1.setTime(parsedTime);
return gc1;
public final static long calculateDuration(java.util.Date a, java.util.Date b) {
Calendar earlier = Calendar.getInstance();
Calendar later = Calendar.getInstance();
if (a.compareTo(b) < 0) {
earlier.setTime(a);
later.setTime(b);
else {
earlier.setTime(b);
later.setTime(a);
System.out.println(earlier.getTimeInMillis() + ":" + later.getTimeInMillis());
long l1 = earlier.getTimeInMillis();
long l2 = later.getTimeInMillis();
return (int)(((l2-l1)/1000) / 60);
}I asked someone in the office and its the first thing they said!!!!!!!!!!!!!!!
So - now fixed and I know for next time.
Thanks - the dukes are yours -
Hi Friends,
I have simple req'.
i have one date filed in OAF page...if user has change the date filed..means if he incresed by 2 days..then i need to call one procedure..if not no need to call....
first am picking that date field to by uusing prepared stmt and putting in to one variable..like below
try {
ps1 = am.getOADBTransaction().getJdbcConnection().prepareStatement("SELECT -------");
ResultSet rs2 = ps1.executeQuery();
while (rs2.next()) {
schDate = rs2.getString(1);//storing the value
} catch (Exception e) {
throw OAException.wrapperException(e);
Next..am picking the current value like this(user can change the value) like below...
OAViewObject viewObj = (OAViewObject)am.findViewObject("simpleVO");
String currSchDate = (String)viewObj.getCurrentRow().getAttribute("iDate");
java.text.SimpleDateFormat dtFormat = new java.text.SimpleDateFormat ("MM/dd/yyyy");
StringBuilder date = new StringBuilder(dtFormat.format(currSchDate));
Then am comparing the values like below..
if (schDate.equals(date)) {
String outParamValue = "";
String secondOutParamValue = "";
but am geting the below error
## Detail 0 ##
java.lang.ClassCastException: oracle.jbo.domain.Date cannot be cast to java.lang.String
at xxuss.oracle.apps.abc.webui.xxPGCO15.processFormRequest(xxGCO15.java:594)
Appriciate any help...its very urgent
Regards
HarryInstead of :
String currSchDate = (String)viewObj.getCurrentRow().getAttribute("iDate");Try
String currSchDate = viewObj.getCurrentRow().getAttribute("iDate").toString();
-Anand -
I have made a ViewObject wich contains a date column.
I want to check if this date is smaller/greater than sysdate:
i get following error:
Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
code:
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
// set up rules for daylight savings time
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
// create a GregorianCalendar with the Pacific Daylight time zone
// and the current date and time
Calendar calendar = new GregorianCalendar(pdt);
Date trialTime = new Date();
calendar.setTime(trialTime);
(VO_ULNRow)singleRow = null;
while(vo.hasNext()){ // ViewObject vo;
singleRow = (VO_ULNRow)vo.next();
if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
etcetera
how can i compare those 2?Hi,
oracle.jbo.domain.Date has two methods which suit your needs
longValue() which returns a long (though I'm not sure if returns a long comparable to the long returned by java.util.Date)
and dateValue() which returns a java.util.Date
I hope it helps,
Giovanni -
Java.util.Date oracle.jbo.domain.Date how can i compare?
I have made a ViewObject wich contains a date column.
I want to check if this date is smaller/greater than sysdate:
i get following error:
Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
code:
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
// set up rules for daylight savings time
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
// create a GregorianCalendar with the Pacific Daylight time zone
// and the current date and time
Calendar calendar = new GregorianCalendar(pdt);
Date trialTime = new Date();
calendar.setTime(trialTime);
(VO_ULNRow)singleRow = null;
while(vo.hasNext()){ // ViewObject vo;
singleRow = (VO_ULNRow)vo.next();
if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
etcetera
how can i compare those 2?i get following error:
Error(45,24): method <(java.util.Date,
oracle.jbo.domain.Date) not found in class Class4
if(calendar.getTime() <
singleRow.getEO_ULN_BORROWFROM()); //singleRow returns
oracle.jbo.domain.Date
how can i compare those 2? You cannot compare these two values directly. You must convert the oracle.jbo.domain.Date object to a GregorianCalendar object. Something like:
oracle.jbo.domain.Date dt = singleRow.getEO_ULN_BORROWFROM();
GregorianCalendar gc = new GregorianCalendar(dt.getYear(), dt.getMonth(), dt.getDay());
if (calendar.getTime() < gc.getTime())
} -
Convert java.sql.Date to oracle.jbo.domain.Date in oaf
Hi,
Need to dafault NeedBydate(i get in from query as below) to a messagelovinput and make it read only.
i am facing some issue in converting from java.sql.Date to oracle.jbo.domain.Date.
unable to figure out the problem.
below is the sample code im trying to use.
PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
ResultSet rs=ps.executeQuery();
if (rs!=null && ps.next()
java.sql.Date sqlDate= rs.getDate(1);
oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
vorow.setAttribute("Datevalue",oracleDate);
this is my assumption : to set to UI i need date in format dd-Mon-yyyy.(am i correct? as to get that format i tried to use simple date format class but no use)
when i tried to use simple date format :unpaseable date exception was raised.
please guide.Hi,
Why are you using this code???
PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
ResultSet rs=ps.executeQuery();
if (rs!=null && ps.next()
java.sql.Date sqlDate= rs.getDate(1);
oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
you can get sysdate using this and then set it
oracle.jbo.domain.Date currentDate = am.getOADBTransaction().getCurrentUserDate();
java.text.SimpleDateFormat displayDateFormat = new java.text.SimpleDateFormat ("yyyy-MM-dd");
String DateForm = displayDateFormat.format(currentDate.dateValue());
oracle.jbo.domain.Date dateset = new oracle.jbo.domain.Date(DateForm);
and then set the attribute
vorow.setAttribute("Datevalue",dateset);
Thanks,
Gaurav
Maybe you are looking for
-
Issue with Instantiation of a Class in Workflow
I created a subclass of CL_HRASR00_WF_PROCESS_OBJECT to include some of my custom methods to be used in the workflow. Since the subclass methods cant be referred using the super class name(as we do in BO) in the standard task , i used a custom method
-
Selecting Pantone Equivalents of Process Colours
I've searched through the forums, and I haven't been able to find anything beside a passing mention covering this topic (but I could be missing the magic word in my search). On a regular basis, we receive artwork from clients that, although pretty, h
-
Working with ObjectOutputStream
I am working with the class ObjectOutputStream, but I dont know what the file extension is that I am working which. Can anyone tell me the type of file this output stream creates?
-
Hi, i had a problem with my system and the blu windows screen appeared. When i started again the system, the database remained in the mounted but not started status. This is the kind of error that i receive if i try to start it. ORA-00368: checksum e
-
I have Virtual PC with Win XP installed on my PowerBook. I can't seem to figure out how to make Win XP - on the VPC - recognize my external HDD, which is connected via USB. I use a wireless keyboard and mouse; they are both connected via USB and are