Java Cookbook
date format
Problem:
You want to format a span of time.
Solution:
As of version 4, icu4j contains a DateIntervalFormat class. This class makes it relatively easy to format an interval value. The format will automatically format as compactly as possible. For example: if the difference between the two dates is only a few hours and both dates occur on the same day, the year, month, and day parts of the date will be omitted.
Calendars and date formatting are central to a properly internationalized application. Java provides several classes that are very useful to the localization developer for handling dates and times.
Java's Calendar class and its sub-classes handle the complex date calculations that go with Chinese, Islamic, Hebrew, and Gregorian calendars, as well as a number of others.
Java's DateFormat class handles formatting dates and times in a locale appropriate manner.
If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.
This site is ad supported. I hope you find something among our sponsors worth clicking. ;)
i18n search