2

I am adding days to the date by this mean "Add day" which is the standard procedure, but unfortunately my Pentaho application breaks on c.setTime(dt);, which I clearly not know the reason as the exception doesn't give any meaning.
So another option is to parse the date and extract month,year, and day and +1 to the day, but I have to then take care of Feburary and odd months. I have just these 2 options in my mind.

Anyone who can guide me with any other option?

the stack trace is

An unexpected error occurred in Spoon:  
(class: Processor, method: processRow signature: (Lorg/pentaho/di/trans/step/StepMetaInterface;Lorg/pentaho/di/trans/step/StepDataInterface;)Z) Register 11 contains wrong type
java.lang.VerifyError: (class: Processor, method: processRow signature: (Lorg/pentaho/di/trans/step/StepMetaInterface;Lorg/pentaho/di/trans/step/StepDataInterface;)Z) Register 11 contains wrong type
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassMeta.getStepIOMeta(UserDefinedJavaClassMeta.java:338)
    at org.pentaho.di.trans.TransPainter.drawLine(TransPainter.java:899)
    at org.pentaho.di.trans.TransPainter.drawHop(TransPainter.java:510)
    at org.pentaho.di.trans.TransPainter.drawHop(TransPainter.java:499)
    at org.pentaho.di.trans.TransPainter.drawTrans(TransPainter.java:184)
    at org.pentaho.di.trans.TransPainter.buildTransformationImage(TransPainter.java:144)
    at org.pentaho.di.ui.spoon.trans.TransGraph.getTransformationImage(TransGraph.java:2728)
    at org.pentaho.di.ui.spoon.trans.TransGraph.paintControl(TransGraph.java:2691)
    at org.pentaho.di.ui.spoon.trans.TransGraph$4.paintControl(TransGraph.java:487)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Composite.WM_PAINT(Unknown Source)
    at org.eclipse.swt.widgets.Control.windowProc(Unknown Source)
    at org.eclipse.swt.widgets.Canvas.windowProc(Unknown Source)
    at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1169)
    at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:6940)
    at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:553)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.pentaho.commons.launcher.Launcher.main(Launcher.java:134)
Community
  • 1
  • 1
  • Please don't write what's already tagged in the title of the question. – Maroun Aug 22 '13 at 10:54
  • What the full stacktrace is? – M. Abbas Aug 22 '13 at 10:55
  • 2
    You should let the hard work be done by Calendar, it was designed to take care of all quirks in timing that we don't know of (e.g., leap seconds and such). Like @mabbas implied, you should figure out why `c.setTime(dt)` breaks. So I concur with him: what was the full stack trace? And: how did you obtain `dt`? Does `dt` need to represent a fixed date, or the current date? – Jelle Fresen Aug 22 '13 at 11:03
  • @JelleFresen please have a look –  Aug 22 '13 at 11:50
  • 1
    It doesn't look like this error is related to `c.setTime(dt)`, I don't see the method invocation to setTime in the stack trace, nor any indication of a method that uses a date/calendar value. Take a look at the description of [Java's VerifyError](http://docs.oracle.com/javase/7/docs/api/java/lang/VerifyError.html). Maybe you're loading an outdated class file? Try cleaning your project, recompile everything and run again. – Jelle Fresen Aug 22 '13 at 12:09
  • @JelleFresen I agree but once you uncomment that line the program runs fine and after adding that line it makes problem –  Aug 22 '13 at 12:22
  • Ok, that is a clear indication :). I did some more reading concerning your error and it looks like there is an error in the bytecode of the method processRow from a class called Processor. [Here](https://github.com/Storyyeller/Krakatau/issues/7) is someone with a similar error, in that case a local variable was loaded without storing anything in it first. – Jelle Fresen Aug 22 '13 at 13:05
  • @JelleFresen aNY sol? –  Aug 22 '13 at 23:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/36107/discussion-between-jelle-fresen-and-user1765876) – Jelle Fresen Aug 23 '13 at 12:27

4 Answers4

2

Also, if you're using Kettle/Pentaho Data Integration, you can use the Calculator step. One of the calculations provided is "Date A + B days". I've used it frequently and it has always worked well for me.

Brian.D.Myers
  • 2,448
  • 2
  • 20
  • 17
1

I got the same issue and here is the solution that worked for me..

This is an issue within the User Defined Java Class

This is caused when trying to access variables that are set within a try/catch block outside the try/catch block (i.e. even if declared prior, but not set until in the try/catch, still get this error).

Soruce - http://jira.pentaho.com/browse/PDI-13032

Sampath Pasupunuri
  • 628
  • 1
  • 13
  • 25
0

Try.

Calender cal=Calender.getInstance();

cal.add(Calender.DATE,1);

an example

    Calendar cal = Calendar.getInstance();
    System.out.println(cal.getTime());// out put Thu Aug 22 16:31:56 IST 2013
    cal.add(Calendar.DATE,1);
    System.out.println(cal.getTime());// out put Fri Aug 23 16:31:56 IST 2013

Check this Demo.

If you try it in this way, this should work fine. please leave a comment or post your code here with the Exception.

Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115
0

Another way to do this is to use Joda time

DateTime dateTime = new DateTime(date);
dateTime = dateTime.plusDays(1);
hermansen
  • 158
  • 3