Tag Archives: date

Student (Java class) example

Here’s my Java source code for a Student class with fields for id, name, and createdDate. The static field counter is used for automatically assigning student id numbers. In another post, I will extend this code for use with generics … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Formatting dates using java.text.DateFormat

Simple example showing use of the DateFormat object: This produced the following output on my computer: Sat Jul 23 09:46:30 ICT 2011 23/07/11 09:46 23-Jul-2011 23/07/11 23-Jul-2011 23 July 2011 Saturday, 23 July 2011

Posted in Uncategorized | Tagged , , | Leave a comment

Java SE 6 Date and Calendar classes (simple example)

This example shows how the Calendar getTime() method can be used to return a Date object. It also demonstrates simple use of the Calendar add() method to increment a date. The program produced the following output: now = Sat Jul … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Getting the current date and time using java.util.Date

Most methods of the Java SE 6 Date class have been deprecated. Nevertheless, it still has its use in providing an an easy way to get the current date and time. Here is a very simple example: When I ran … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment