Enter your keyword

Blog

Get Current Date using Java

Below code give current date in String. import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar; public class CurrentDate {    public CurrentDate() {        super();    }     public static void main(String[] args) {        DateFormat dateFormat = […]

Current Date in GregorianCalendar using java

Code snippet that will give Current date in GregorianCalendar format: import java.util.GregorianCalendar;import javax.xml.datatype.DatatypeConfigurationException;import javax.xml.datatype.DatatypeFactory;import javax.xml.datatype.XMLGregorianCalendar; public class CurrentDate {    public CurrentDate() {        super();    }     public static void main(String[] args) […]

Java Jndi datasource lookup

JNDI style is typical when using an application server(Weblogic, JBOSS) or a web container(Apache Tomcat). Here’s a example of the lookup Datasource created in Server. import java.sql.Connection;import java.sql.SQLException;import javax.naming.Context;import javax.naming.InitialContext;import […]

Map Interface in Java

import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.Map.Entry;import java.util.Set; public class MapImplementation {    public MapImplementation() {        super();    }        public static void main(String args[]){        Map<Integer,String> map = new HashMap<Integer,String>();                // Addition of […]