April 30, 2012 at 9:08 pm
· Filed under Java
How many times have you got a millisecond long timestamp and had to compare it to a duration e.g. 1000 * 60 * 60 * 24 * … ? I stumbled upon this more readable and less error prone way of representing, say, 5 hours, by using the java.util.concurrent.TimeUnit.
private static final long FIVE_HOURS = TimeUnit.MILLISECONDS.convert(5, TimeUnit.HOURS);
...
if (timestamp < System.currentTimeMillis() - FIVE_HOURS) {
// do something.
}
The above will check if a timestamp is overdue for more than five hours. The variable twoDays will have the value 172800000. TimeUnit supports from nanoseconds, micro-, milli-, all the way up to days.
However, if the date/locale is important to you (e.g. daylight savings) then you should use the Calendar API/JodaTime rather than this “duration”-based TimeUnit.
Permalink
April 12, 2012 at 3:29 pm
· Filed under Java
Unless your jasper reports change at runtime, .jrxml templates should be compiled at compile time into .jasper, and you will not need JDT at runtime, nor need to re-compile the reports each time it is run.
If you’re on maven, simply paste the usage guide into your pom and change your JasperCompileManager.compileReport(InputStream) into JRLoader.loadObject(InputStream).
Permalink
March 5, 2012 at 11:41 am
· Filed under Tech
This day finally came when I copied/paste the wrong bug number into the SVN commit message. Usually errors in SVN commit messages can be ignored but this particular one may lead to much confusion later. Luckily there was a way to edit the commit message after it’s committed. As usual I paste the command here instead of just the reference link as I have already some posts that have dead reference links.
svn propset -r 12345 --revprop svn:log "#1234 description"
where 12345 is the revision number, and text in quotes is the corrected commit message.
I still prefer to be cautious to commit messages correctly, but humans are just humans…
Ref: http://subversion.apache.org/faq.html#change-log-msg
Permalink
February 23, 2012 at 12:17 pm
· Filed under Tech
I installed the latest and greatest TortoiseSVN on a new PC (which happen to be for SVN 1.7), and happily upgraded my working copy when prompted. Newer is better isn’t it? After all, I didn’t like the .svn folder everywhere, which 1.7 got rid of with centralized metadata storage.
To my horror later, Netbeans wouldn’t update my workspace anymore, since the current version has no way to support 1.7 yet, other than the command line client. Fine, I installed the 1.7 CLI over my 1.6 CLI, but the Subversion features in Netbeans became sluggish and often show incorrect change flags until I manually activated Show Changes each time.
Downgrading to 1.6 was not an easy feat, I installed TortoiseSVN 1.6.16, judging by it being the latest release bound to SVN 1.6. I was lucky my SVN server is local so re-checking out my workspace was not that tough (I know some places which will take hours, and I haven’t found a “downgrade working copy” method that didn’t require a checkout).
Then Netbeans complained the working copy isn’t compatible anymore with my SVN 1.7 CLI. I cleared the SVN path setting, but couldn’t find any option to force it to revert to using the built-in bindings. Reinstalling the plugin did not help either. A half hour later I resorted to a brute force search on “subversion” in the netbeans folder and my home folder and I finally found this file:
C:\Users\%USERNAME%\.netbeans\7.1\config\Preferences\org\netbeans\modules\subversion.properties
where the option “forcedCommandline” is set to true. Changing it to false and restarting my IDE got me out of the situation and ended my fight with SVN 1.7. I still like the idea of the new working copy, so hopefully a new NB SVN plugin will be released soon.
Permalink
January 25, 2012 at 10:35 am
· Filed under Tech
My mailbox gets full frequently despite constant archiving. I check the folder size using my mailbox properties to help me clear the problem areas since it shows the distribution of the data amongst the server folders. Most folders get cleared out, but one area that starts to build up over time in my Server Data’s folder list is the “Sync Issues\Conflicts”, which I could not clear.
Today I finally found the folder in “Go > Folder List > (left navigation panel)”, and managed to clear it out. To go back to the original folders, click “Go > Mail”.
Permalink