Adding one day to a oracle.jbo.domain.Date and truncating the time part
JDev 11.1.1.4.0
Hello
I need to add a day to oracle.jbo.domain.Date and get back a oracle.jbo.domain.Date without the time part.
So far I've got
Date valueDate = (Date)rowCpt.getAttribute("ValueDate");
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
cal.add(Calendar.DATE, 1);
Date newDate = new oracle.jbo.domain.Date(new Timestamp(cal.getTime().getTime()));This adds 1 day to the date but keeps the time part of the date.
How do I get rid of the time part of the date ?
Thanks
Paul
The Calendar class allows you to set or clear each field.
Date valueDate = (Date)rowCpt.getAttribute("ValueDate");
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
cal.add(Calendar.DATE, 1);
cal.clear(Calendar.HOUR);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
Date newDate = new oracle.jbo.domain.Date(cal.getTimeInMillis());should work.
Timo
Similar Messages
-
Oracle.jbo.domain.Date and JavaDoc
Is there any javadoc for oracle.jbo.domain.Date etc?
If not then what is the constructor?
What format is the String passed in?....DD/MM/YY ???
Can you pass in a java.util.Date to the constructor?
Thanks,
Paul.http://otn.oracle.com/jdeveloper/help/topic?inOHW=true&linkHelp=false&file=jar%3Afile%3A/u01/webapps/OHW/ohw-app/jdeveloper/helpsets/jdeveloper/reference/reference.zip!/bc4jdomorcldoc/oracle/jbo/domain/Date.html
-
Problem with oracle.jbo.domain.Date and format 'dd.MM.yyyy'
JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value: 09.10.2003
In EOImplMsgBundle :
{"Dbeg_FMT_FORMATTER", "oracle.jbo.format.DefaultDateFormatter"},
{"Dbeg_FMT_FORMAT", "dd.MM.yyyy"}};
In VOImplMsgBundle :
{"Dbeg_FMT_FORMAT", "dd.MM.yyyy"},
{"Dbeg_FMT_FORMATTER", "oracle.jbo.format.DefaultDateFormatter"},
Why ? Help PleaseI have the same problem !
I have extended the formatinfo.xml with:
<DOMAIN CLASS="oracle.jbo.domain.Date">
<FORMATTER name="Simple Date" class="oracle.jbo.format.DefaultDateFormatter">
<FORMAT text="dd.MM.yyyy" />
<FORMAT text="dd-MM-yyyy" />
<FORMAT text="yyyy-MM-dd" />
<FORMAT text="yyyy-MM-dd G 'at' hh:mm:ss" />
<FORMAT text="EEE, MMM d, ''yy" />
</FORMATTER>
</DOMAIN>
And then I have set my attibutes to use this FORMATTER with FORMAT "dd.MM.yyyy".
When I start my application, I became an error and the date-fields are blank ... The application can not convert my Date in 'dd.MM.yyyy' format ...
When I set my attributes to Format Type <none>, it works, the date-fields are present ... -
How do I use oracle.jbo.domain.Date truncate() method?
Hello -
I want to get the equivalent of "trunc(SYSDATE)" in the form of an oracle.jbo.domain.Date instance.
I think I can do this by getting the current date and truncating the time portion:
Date myDate = Date.getCurrentDate();
myDate.truncate(some_precision_string);
Issue is: what do I use for the precision string? (Javadoc for class (and its parent) is not helpful...)
Thanks,
-- ScottNevermind. Apparently these methods don't really exist.
(Although documentation in 9.0.3.3 JDev under Help -> Help Topics -> Contents Tab -> Reference -> Business Components Oracle Domains (this one is a javadoc page) say that they do....) -
Set oracle.jbo.domain.Date object to null
Hi
We have a case where we need to set a Date value to null.
We have tried row.setCxdDate(null) and row.setCxdDate(new Date("")), but to no avail.
When we call DBTransaction.commit() in the application module, all the other changes are persisted to the database, except for the date. No exceptions are generated at all.
I have searched through these forums, and the only thing I have come up with, was that this was filed as a bug to be fixed in the 9.0.3 release; we are using 10.1.2!
Does anyone know how to solve this?
TIA
GarethIt returned "1970-01-01"
By the way I found that there is one method getTime() in oracle.jbo.domain.Date class
http://otndnld.oracle.co.jp/document/products/as10g/101300/B25221_03/web.1013/b16007/oracle/jbo/domain/Date.html used in 10.3
But could not find it while using in JDeveloper 11.1.1.3 <http://download.oracle.com/docs/cd/E17904_01/apirefs.1111/e10653/oracle/jbo/domain/Date.html>
Edited by: Moinak on Mar 4, 2011 7:08 AM
Edited by: Moinak on Mar 4, 2011 7:10 AM -
Oracle.jbo.domain.Date blows on NoSuchMethodError
The following statement:
oracle.jbo.domain.Date nowDate = new oracle.jbo.domain.Date(nowTime);
has the following run time error when I try to run the main class in the production library:
Exception in thread "main" java.lang.NoSuchMethodError
at stkpackage1.test3.main(test3.java:147)
Of course, it runs fine in JDeveloper on the same machine.
The JDeveloper and the production environment appear to have the same version of Java: 1.3.1_04 (Linux).
Any hints? Any way to debug?
-- EwinCheck the classpath for the run in the IDE and verify that the path is same for the production setup. It seems either jbo.domain.Date or one of it's superclasses is missing in your classpath.
-
Problems Validating an Attribute of type oracle.jbo.domain.date
I have a form that has a date input field. I am trying to customise the exception error for this field for when the user enters something other than my dd/MM/yyyy format. ie JBO-25009: oracle.jbo.domain.DataCreationException
This Attribute uses a the oracle.jbo.domain.date data type. An exception is finally thrown when the transaction trys to commit.
My problem is that I can't customise the exception because I can't catch where it is occuring. I have tried at the <setAttributeInternal>, <setAttribute> and <validateEntity> levels uses both try{}catch(Jbo Exception){} and try{}catch(AttrValException){}. I believe the reason for this is because the problem occurs because the parse value to functions are invalid dates so it never enters them.
If this is true validation and any exception thrown should occur at the data type level, but the the oracle.jbo.domain.date class doesn't have a validate method.
Can someone please help me get around this problem. Or tell me if the have a solution for date input validation.The usecase is as follows:
I have a DynaAction Form with a input field for a date value. This field in the form is associated with an entity attribute that is of the type oracle.jbo.domain.date
In the message bundle for this entity I specify a format (dd/MM/yyyy) and formatter for the field (oracle.jbo.format.DefaultDateFormatter). In the jsp page I display the field using the following tag within the <jbo:row> tags,
<jbo:InputDate dataitem="ChangeDate" formname="ApplicationReleaseForm"/>
The date picker script works well here and the formatter formats it correctly.
My error occurs when an invalid date value is entered. Ie characters like "abc" or numeric values that don't match a date format ie my date format (dd/MM/yyyy) or the default format of the jbo.domain.date type(yyyy-MM-dd).
On submitting my form the input is posted to an action that extends the Update action class. I use the following expression to cache the input from the form in the viewobject:
ActionForward actionForward = super.execute(mapping,form,request,response);
The invalid input appears to be able to slip through this call without causing an exception, unless I make the attribute manditory. In this case an exception is thrown causing the form to be returned and the mandatory value error message to be shown.
If the attribute is not mandatory the exception is not thrown until I make a call to commit; eg
context.getApplicationModule().getTransaction().commit();
The DataCreationException is the initial exception that is caught and causes the rest of the transaction to fall over.
It is my understanding that if the input is wrong then it should be picked up when the form data is pushed into the viewobject, ie in the call to execute and at the setAttributeInternal() method call for the attribute in the viewobject. I don't believe that the input gets this far as the input is not a valid date, indicating to me that the oracle.jbo.domain.date should be the object throwing the exception.
I hope this gives you a better understanding of the process and where and what causes the problem to occur. -
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. -
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 -
Business Components and oracle.jbo.domain.Date
Hello I have the next problem I have a Busines Component and I have to acess to rows who have Dates and with oracle.jbo.domain.Date I can4t acess to the day, month, year .
Can anyone Help me how can I do to access this dates?
Thanks a lot your your help.Hi,
This is the trilogy problem:
oracle.jbo.domain.Date
oracle.sql.DATE
java.util.Date
The question is how to translate from one object type to another.
You can use the following:
oracle.jbo.domain.Date tmpDate = null;
SimpleDateFormat tmpLocalFormat = new SimpleDateFormat();
SimpleDateFormat tmpLocalFormat2 = new SimpleDateFormat();
// Obtenir la date du sommaire
tmpDate = (oracle.jbo.domain.Date) session.getValue("DateElem");
// Initialisation des objets de formatage de date
tmpLocalFormat.applyPattern("yyyy-MM-dd");
tmpLocalFormat2.applyPattern("dd-MM-yyyy");
// Conversion du format de date yyyy-MM-dd => dd-MM-yyyy
tmpWhereClause = new String(tmpLocalFormat2.format(tmpLocalFormat.parse(tmpDate.toString())));
// Ajouter ` la clause "Where" la contrainte de la date
tmpWhereClause = "DrqSommaireInitial.DATE_SOMMAIRE = TO_DATE('" + tmpWhereClause + "', 'DD-MM-YYYY')";
Take a look also to class calendar...
null -
How to truncate oracle.jbo.domain.date
Hi,
I have problem to convert oracle.jbo.domain.date. Now I got current date from pagecontext, but it is yyyy-mm-dd hh:mi:ss format. I want to only yyyy-mm-dd, so I want to truncate the time from oracle.jbo.domain.date. And I want to got Date object not string. I found there is Date.truncate(), but I don't know how to use it.
Could some one to help to give me a example?
Best Regards,
EileenAfter spandig a lot of time with this I have found that the method is not implemented!!!
Use this:
public static oracle.jbo.domain.Date trunc(oracle.jbo.domain.Date dt,String fmt) {
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(fmt);
String s= sdf.format(dt.getValue());
java.sql.Timestamp ts;
try {
ts = new java.sql.Timestamp(sdf.parse(s).getTime());
dt=new oracle.jbo.domain.Date(ts);
} catch (ParseException e) {
return dt;
}To trunc to hours use format e.g. "dd.MM.yyyy HH"
Karel
Edited by: Karel.Redl on 26.11.2009 6:48 -
How to convert String (dd-MMM-yyyy) to oracle.jbo.domain.Date
Hi
Could you please tell how do I convert String of date in format dd-MM-yyyy to ADF date? Please show me some sample.
Thankshttp://javaalmanac.com/egs/java.text/FormatDateDef.html
Once you have a java.util.Date you can convert it to oracle.jbo.domain.Date. (see http://www.fifkredit.com/bc4jdoc/rt/oracle/jbo/domain/Date.html) -
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 -
GetCurrentDate() not found in oracle.jbo.domain.Date;
Is it a known bug.
Then how do we get the current date and time?
Thanks in advance.Viani - you're right, but oracle.jbo.domain.Date is definitely not right - see Calendar as suggested above.
John -
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())
}
Maybe you are looking for
-
3.1.2 installation problems
Have anyone installed succesfully installed APEX 3.1.2? I can not aconect to the administration services ... I getting the window for credential again and again . My database is Oracle EE 10.2.0.3 on Windows XP platform . I downloaded the file with e
-
Does anyone have a problem with opening PDF files in iBook after updating the program recently
I need to try to open the pdf file a few times before it goes in iBook. It is making me look like a fool cos I use iBook for my presentation to my clients
-
Hi there, I have some questions about cvs daily snapshot. The problem is for the package eo-snapshot in AUR Here is the PKGBUILD # Contributor: Sebastien Piccand <[email protected]> pkgname=eo-snapshot pkgver=20060411 _ver=11Apr2006 pkgrel=1 pkgdesc=
-
Is there a way to select within if block
Hi I want to do something like the followings DECLARE empcnt number ; BEGIN BEGIN select count(*) into empcnt from employees where status = 'L'; EXCEPTION WHEN NO_DATA_FOUND THEN empcnt := 0;
-
TS1406 I have followed all instructions to try and fix the "not a Win32 app"
but I still get the error. Anything else I should try?