|
Java example source code file (index.md)
The index.md Java example source code
## <i> About
Joda-Time provides a quality replacement for the Java date and time classes.
Joda-Time is the *de facto* standard date and time library for Java prior to Java SE 8.
Users are now asked to migrate to `java.time` (JSR-310).
Joda-Time is licensed under the business-friendly [Apache 2.0 licence](license.html).
## <i> Features
A selection of key features:
* `LocalDate` - date without time
* `LocalTime` - time without date
* `Instant` - an instantaneous point on the time-line
* `DateTime` - full date and time with time-zone
* `DateTimeZone` - a better time-zone
* `Duration` and `Period` - amounts of time
* `Interval` - the time between two instants
* A comprehensive and flexible formatter-parser
## <i> Documentation
Various documentation is available:
* The [getting started](quickstart.html) guide
* The helpful [user guide](userguide.html)
* The [key concepts](key.html) and [chronology](cal.html) guides
* The [Javadoc](apidocs/index.html)
* The list of [FAQ](faq.html)s.
* The [change notes](installation.html) for each release
* The [GitHub](https://github.com/JodaOrg/joda-time) source repository
---
## <i> Why Joda Time?
The standard date and time classes prior to Java SE 8 are poor.
By tackling this problem head-on, Joda-Time became
the de facto standard date and time library for Java prior to Java SE 8.
**Note that from Java SE 8 onwards, users are asked to migrate to `java.time` (JSR-310) -
a core part of the JDK which replaces this project.**
The design allows for multiple calendar systems, while still providing a simple API.
The "default" calendar is the [ISO8601](cal_iso.html) standard which is used by many other standards.
The Gregorian, Julian, Buddhist, Coptic, Ethiopic and Islamic calendar systems are also included.
Supporting classes include time zone, duration, format and parsing.
As a flavour of Joda-Time, here's some example code:
<div class="source">
<pre>
public boolean isAfterPayDay(<a href="apidocs/org/joda/time/DateTime.html">DateTime datetime) {
if (datetime.getMonthOfYear() == 2) { // February is month 2!!
return datetime.getDayOfMonth() > 26;
}
return datetime.getDayOfMonth() > 28;
}
public <a href="apidocs/org/joda/time/Days.html">Days daysToNewYear(LocalDate fromDate) {
<a href="apidocs/org/joda/time/LocalDate.html">LocalDate newYear = fromDate.plusYears(1).withDayOfYear(1);
return <a href="apidocs/org/joda/time/Days.html">Days.daysBetween(fromDate, newYear);
}
public boolean isRentalOverdue(<a href="apidocs/org/joda/time/DateTime.html">DateTime datetimeRented) {
<a href="apidocs/org/joda/time/Period.html">Period rentalPeriod = new Period().withDays(2).withHours(12);
return datetimeRented.plus(rentalPeriod).isBeforeNow();
}
public String getBirthMonthText(<a href="apidocs/org/joda/time/LocalDate.html">LocalDate dateOfBirth) {
return dateOfBirth.monthOfYear().getAsText(Locale.ENGLISH);
}
</pre>
</div>
## <i> Rationale
Here are some of our reasons for developing and using Joda-Time:
* <b>Easy to Use.
Calendar makes accessing 'normal' dates difficult, due to the lack of simple methods.
Joda-Time has straightforward <a href="field.html">field accessors such as
<code>getYear() or
Other Java examples (source code examples)Here is a short list of links related to this Java index.md source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.