Monday, November 24, 2008

Convert integer to any base

System.out.println(Integer.toString(31, 16));

Answer is : 1f

This means 31 into base 16 is 1f.

Monday, November 17, 2008

create temporary table in informix

create temp table incomplete(id serial," +
"mobile_no varchar(50)," +
"totalNumber integer," +
"repeated integer," +
"achieved varchar(50))WITH NO LOG


when you execute the sql it will make the temporary table "incomplete" in database server temp space with no logs.

when you close the connection this type of table will be dropped. Sometime, you may have to drop it manully too.

Sunday, November 9, 2008

How to validate date using js

function getValidateDate(){
var tmp=true;

var strFrom=document.getElementById("txtFrom").value;
var strTo=document.getElementById("txtTo").value;

if(strFrom!='' && strTo!=''){
var fdate=strFrom.split('-');

var tdate=strTo.split('-');

var strFDate=new Date();
strFDate.setFullYear(fdate[0],fdate[1],fdate[2]);

var strTDate=new Date();
strTDate.setFullYear(tdate[0],tdate[1],tdate[2]);

if(strTDate<strFDate){
alert(strFrom +" is after "+ strTo);
tmp=false;
}
}else{
alert("Date period must be filled");
tmp=false;
}

return tmp;
}


call the getValidateDate() method as follows in the form.

onsubmit="return getValidateDate()"

Thursday, November 6, 2008

Java generics

Vector <String> vec = new Vector<String>();
if you create a vector like this,
you can only add String objects in to it.
this is simply called as Generics

Value rounding in java

use the following method to value round in java


double round = 134.23445;
java.text.NumberFormat nf = new java.text.DecimalFormat("0.00");
System.out.println(nf.format(round));
if you need to round a value to three positions
new java.text.DecimalFormat("0.000");

Essential libraries for Jasper developers

Essential libraries for jasper runtime
  1. commons-collections-2.1.jar
  2. jasperreports-2.0.3.jar
  3. poi-3.0.1-FINAL.jar
Jasper compiler
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
public class Main {
public static void main(String[] args) {
try {
System.out.println("compiling");
JasperCompileManager.compileReportToFile("d:\\Complaint.jrxml");
System.out.println("done");
} catch (JRException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}