Category Archives: Java

Java – Get current Unix timestamp from date string

The following piece of Java code could convert a date string into a Unix timestamp.

String dateString = "Fri, 09 Nov 2012 23:40:18 GMT";
DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss z");
Date date = dateFormat.parse(dateString);
long unixTime = (long)date.getTime()/1000;
System.out.println(unixTime); //<- prints 1352504418


Done =)



Maven – Add Java classpath to manifest for runtime

Previously we have talked about how to package a .jar artifact with dependencies included.


An alternative solution is to put your dependencies in the src/main/resources folder and they will be copied to the target folder together with the packaged .jar file. Then we can add the class paths to these dependencies in the Manifest with the help of the maven-jar-plugin.

The following project is a real life example which i use it to test the connection between the JBoss server and the MSSQL server.
Continue reading Maven – Add Java classpath to manifest for runtime

Jenkins – Setup a simple Ant build project

Jenkins, previously named as Hudson, is a continuous integration tool just like CruiseControl. It has been almost 4 years since i started learning Maven which made me fall in love about best practice. Deployment and testing automation is really fun and finally i got a chance to play it again.

In this article, i would show you how to setup a simple Ant build project in Jenkins. Before we start, please refer to the simple Java project example in the post below.


1. Download and install Jenkins.
Continue reading Jenkins – Setup a simple Ant build project