Search code examples
javajasper-reports

How to get date six month before current date in single line in Java?


I want to get a date six month before from present date. The code that I tried is:

SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -6);
System.out.println(format.format(c.getTime()));

But I want to reduce this to a single line expression which I want to use in my Jasper report to put in parameter expression.

How can I reduce it to single line expression?


Solution

  • wrap this util method into a Utility class build the jar and put it in classpath of your iReport and whenever you are compiling this jrxml