Tag Archives | java

How to change Java Version in Linux?

In this article, you will see how to change default java version to latest version.Check the current version used on your system. [root@localhost /]# java -version Example Output java version “1.4.2″gij (GNU libgc) version 4.1.2 2008704 (Red Hat 1.4.2-48) If there are multiple versions of java, you can change the default version by executing following [...]

Continue Reading ... Comments { 0 }

JDBC Introduction

The Java Database Connectivity (JDBC) API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases– SQL databases and other tabular data sources, such as spreadsheets or flat files. The JDBC API provides a call-level API for SQL-based database access. JDBC technology also provides a common base [...]

Continue Reading ... Comments { 0 }

Date Formatting using SimpleDateFormat in Java

In this article, you will see how to format date using SimpleDateFormat in Java When you run the above example you’ll get an output like: Current Date: 11/22/2012 10:29:28

Continue Reading ... Comments { 0 }

Convert String to Date in Java

In this article, you will see how to convert string to date format in Java When you run the above example you’ll get an output like: Thu Nov 22 00:00:00 IST 2012

Continue Reading ... Comments { 0 }

How to get Current Timestamp in Java

In this article, you will see how to get current timestamp in Java Using Date Class Using Calendar Class When you run the above example you’ll get an output like: 2012-11-22 10:04:18.843

Continue Reading ... Comments { 0 }

How to use JNDI to get database connection or data source

In this tutorial you will learn, how to use JNDI to get database connection or data source. Tools and Technologies used: Java 5 or above Eclipse Indigo Spring MVC 3.0 MySQL 5.5 JBOSS Server 4.2.2 First create a new Dynamic Web Project and configure it as Maven Project. For Reference, Click Here Add the following [...]

Continue Reading ... Comments { 0 }

How to find difference between dates in Java

In this article, we will show you how to find difference between dates. Using Date Class Using Calendar Class When you run the above examples you’ll get an output like: Date 1 2012-08-07 05:30:23 Date 2 2012-08-08 11:24:56Milliseconds = 107673000 Seconds = 107673 Hours = 1794 Hours = 29 Days = 1

Continue Reading ... Comments { 0 }

How to compare dates in Java

In this article, we will show you how to compare dates. Using Date.CompareTo() method If both dates are equal, compareTo will return 0 If Date1 is after Date2, compareTo will return value greater than 0 If Date1 is before Date2, compareTo will return value less than 0 Using Date.After(), Date.Before() and Date.Equals() method Using Calender.After(), [...]

Continue Reading ... Comments { 0 }

How to convert Java Object to / from JSON (Using Gson)

In this article, you will see how to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson is an open-source project hosted athttp://code.google.com/p/google-gson Add the following dependencies in pom.xml 1. Create POJO Create Person Class as following. 2. Convert to JSON [...]

Continue Reading ... Comments { 0 }

How to convert byte[] to blob in Java

In this article, you will see how convert byte[] to blob and vice versa in Java. How to convert a Blob into a byte array

Continue Reading ... Comments { 1 }