I have a java code where I am calculating the current time stamp as follows: int mon = rightNow.get(Calendar.MONTH) + 1; if (mon < 10) str += "0" + mon; else str += mon; int day = rightNow.get(Calendar.DAY_OF_MONTH); if (day < 10) str += "0" + day; else str += day; int hr = rightNow.get(Calendar.HOUR_OF_DAY); if (hr < 10) str += "0" + hr; else str += hr; int min = rightNow.get(Calendar.MINUTE); if (min < 10) str += "0" + min; else str += min; return(str);
Now I need final value to be set as a ant property .
I'm afraid you didn't mention how you were getting from Java into Ant. However, there are much simpler ways to format dates than by building them up with low-level string code.
I'd also verify that the Ant datestamp task doesn't already do what you need without requiring extra Java code.
An IDE is no substitute for an Intelligent Developer.
Joined: Sep 19, 2008
I am using ant script to create the jad and jar file. In that I need to log the build date in text file. The same build date is required to be logged in the jad and manifest file. So, I need the same value which was generated by java code, to be used while building jar package.