JODA-TIME / NOTES</>↗Joda-Time02 Feb 2012
This example show us how to use Joda-Time’s DateTime class to get the last day of the month. To get the last day of the month we first need to find out the last date of the month. To do this, create a new instance of a DateTime. From the DateTime object get the day-of-the-month […]
JODA-TIME / NOTES</>↗Joda-Time01 Feb 2012
The following example show you a various way to create an instance of Joda-Time’s DateTime class. By using the default constructor we will create an object with the current system date time. We can also create the object by passing the information like year, month, day, hour, minutes and second. Joda can also use an […]
JODA-TIME / NOTES</>↗Joda-Time01 Feb 2012
The org.joda.time.DateMidnight class represent a date time information with the time value set to midnight. The following snippet show you how to instantiate this class. package org.kodejava.joda; import org.joda.time.DateMidnight; import org.joda.time.format.DateTimeFormat; public class DateMidnightDemo { public static void main(String[] args) { // Create DateMidnight object of the current system date. DateMidnight date = new DateMidnight(); […]
CORE API / NOTES</>↗Core API16 Jan 2012
This code snippet show you how to create an array of unique numbers from another array of numbers. package org.kodejava.lang; import java.util.Arrays; public class UniqueArray { /** * Return true if num appeared only once in the array. */ public static boolean isUnique(int[] numbers, int num) { for (int number : numbers) { if (number […]
XML / NOTES</>↗XML11 Jan 2012
This example show you how to get the attributes of elements in an XML file using the SAX parser. package org.kodejava.xml; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import java.io.InputStream; public class SAXElementAttribute { public static void main(String[] args) { SAXElementAttribute demo = new SAXElementAttribute(); demo.run(); }...
XML / NOTES</>↗XML10 Jan 2012
The ErrorHandler interface implemented by the org.xml.sax.helpers.DefaultHandler class provides some methods for error handling mechanism in SAX parsing. The methods are warning(), error(), and fatalError(). package org.kodejava.xml; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import java.io.InputStream; public class SAXErrorHand...