Date « Data Types « Java Articles

Java Articles
1. Build Deploy
2. Class
3. Core Library
4. Data Types
5. Database JDBC
6. Design
7. Development
8. File Input Output
9. Graphics Desktop
10. J2EE Enterprise
11. J2ME Wireless
12. JVM
13. Language
14. Library Product
15. Network
16. Security
17. SOA Web Services
18. Test
19. Web Development
20. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Articles » Data Types » Date 
1. Solve the date-selection problem once and for all
"Date selection is a problem that pops up every few months when you build client-side graphical user interfaces (GUIs). Unfortunately, Java doesn't provide anything like a DateChooser class, and the date-selection widgets I found in a recent Web search were too heavyweight for my purposes. I wanted something clean, unobtrusive, and flexible. Figure 1 shows a few variants of this article's class, so you can see what I mean by "clean" at the display level."

2. Calculating Java dates
"The getDateInstance method shown in the code above, with no arguments, creates an object in the default format or style. Java also provides some alternative styles for dates, which you can obtain through the overloaded getDateInstance(int style). For convenience' sake, DateFormat provides some ready-made constants that you can use as arguments in the getDateInstance method. Some examples are SHORT, MEDIUM, LONG, and FULL, which are demonstrated in the program below:"

3. Travel through time with Java
"Scientists believe you need a wormhole (or some other exotic device) to travel through time. But in 2002, I discovered another way to visit the past and any one of the many possible futures. All this computer-based technique requires is an appropriate programming language, such as Java. I prefer to use Java because Java's support for big integers and buffered images greatly facilitates the implementation of this technique."

4. My kingdom for a good timer!
"You will discover that results vary based on your platform. Java developers on Linux enjoy 1-millisecond (ms) resolution, while Windows 98 users suffer with 50-ms resolution. In most cases, the actual resolution has nothing to do with the fact that System.currenTimeMillis()'s return value is current time in milliseconds."

5. Timezones, Daylight Savings Time, and the Sun TZupdater for the Java Runtime Environment (JRE)
"Since DST policy is set by national and regional governments, changes in DST policy occur at different times in different countries. Some countries are currently extending their DST periods, thereby changing the dates on which DST will come into effect in a given year. Some countries do not implement any DST at all. So, regardless of where in the world you live, you should anticipate that changes in DST and timezone rules might occur at some point, and be ready to adjust clocks accordingly on the approved dates when these decisions are made. For Java technology-based applications that need to know the exact time in a given location, it is recommended to keep the Java Runtime Environment (JRE) software updated with these latest DST rules. See Timezone Data Versions in the JRE Software to see which Olson data version is included in your version of the JRE software."

6. Internationalizing dates for your Java app
"The life of a Java programmer: after you write and deploy your app, you get an e-mail, written in French. After translation, it turns out to be mail flaming you for not putting your date in European format. Ouch!"

7. Back to Basics with Dates, Calendars, and Formatters
"And there you have it. Pick two dates, feed a Calendar object representation of them into this method, and it will tell you how many days they are apart. This method could be modified to work on months instead of days, and there is even a convenient HOUR_OF_DAY field value to do similar comparisons on an hourly basis (which, if you or your code works in one of the US regions with DST, might be worth using at least two days out of the year)."

8. Class of the Month: GregorianCalendar
"Business applications often require date and time calculations. Furthermore, in a global environment, these calculations must be localized for various geographical regions in which the application is running. The Java platform took a huge step in streamlining the way it deals with date and time by introducing the abstract java.util.Calendar class. Subclasses of Calendar interpret a date according to the rules of a specific calendar system. One such subclass is java.util.GregorianCalendar. You can use the methods and properties of GregorianCalendar for many of your date and time calculations and comparisons."

www___.___j__a___va_2__s___.__c__om_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.