Class: TimezoneDateTime
Author: Shahrzad Jahangirian
Language: Java (using Java 6) Download Java 6 and
Download Java Runtime 6(JRE)
Date Added: Dec 5, 2013
Description: TimezoneDateTime class has one method as createFormattedDateTime that uses two
parameters to give Date, Time, or Both for specific location on Earth to the user in
stylized format. I coded 26 different Date and Time formats and you may add much more by
following my structured coding.
First Parameter must be a Java Timezone ID such as
Australia/Melbourne
America/Los_Angeles
and second parameter is a number that gives you the selected formatted output from 1 to 26.
You may see all available Java Timezone id by using this code
How to Run: I tested all codes on Windows 7 Command Prompt with
Java(TM) SE Runtime Environment 6 on my computer. ( you may download it by visiting
this link )
You need to create all files and save it in a folder in your computer such as C:\javacodes
and compile and run at command prompt as follows. I assumed you saved all files at C:\javacodes
C:\javacodes> javac TimezoneDateTime.java -d c:\javacodes "this statement compiles the class and creates TimezoneDateTimePKG package"
C:\javacodes> javac Timezone.java "compiles the Main class"
C:\javacodes> Java Timezone "and this statement runs the Timezone.java"
and the result will be
1) Wed, 4 Dec 2013
2) 4/12/2013
3) Wednesday, 4 December 2013
4) 4 December 2013
5) 4/12/13
6) 2013-12-04
7) 4-Dec-13
8) 4.12.2013
9) 4 Dec. 13
10) December 13
11) Dec-13
12) 4/12/2013 8:22pm
13) 4/12/2013 8:22:06pm
14) 8:22PM
15) 8:22:06PM
16) 20:22
17) 20:22:06
18) December 4, 2013 at 8:22
19) 2013.12.04 AD at 20:22:06 EST
20) Wed, Dec 4, '13
21) 08 o'clock PM, Eastern Summer Time (New South Wales)
22) 8:22 PM, EST
23) 02013.December.04 AD 08:22 PM
24) Wed, 4 Dec 2013 20:22:06 +1100
25) 131204202206+1100
26) 2013-12-04T20:22:06.410+1100
Below is the TimezoneDateTime Java class code
At the bottom is the Main class that runs createFormattedDateTime and it displays all 26 formatted Date and Time.