Using JODA to deal with the time(2)User Guide

本文介绍了JODA-Time的时间处理类,包括DateTime、Interval、Duration和Period等关键概念。探讨了瞬时、区间、期间、持续时间和周期的实现方式,并提供了实际应用案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Using JODA to deal with the time(2)User Guide
Introduction
Usage of the key DateTime, Interval, Duration and Period classes.

Architecture Overview
There are the concepts of instant, interval, period, duration, chronology and timezones.

Instants
The millisecond instant can be converted to any date time field.

Fields and Properties
The property class associated with DateTime is DateTime.Property.

Intervals
An interval in JODA-Time represents an interval of time from one instant to another instant.

Intervals are implemented as half-open, which is to say that the start instant is inclusive but the end instant is exclusive.

Durations
Durations have no chronology or time zone, and consist solely of the millisecond duration.

Periods
Periods are inexact in terms of milliseconds.

For example, 1 month is quite different in February.

Periods are implemented as a set of int fields. The standard set of fields in a period are years, months, weeks, days, hours, minutes, seconds and milliseconds.

Chronology
…snip…

TimeZones
var zoneUTC = DateTimeZone.UTC
println("DateTimeZone Object = " + zoneUTC)

Querying DateTimes
var iDow = dt.getDayOfWeek()
println(iDow) // 1=MONDAY, SUNDAY=7

var propertyDow = dt.dayOfWeek() //DateTime.Property
println(propertyDow.getAsShortText() + " " + propertyDow.getAsText())

Manipulating DateTimes
DateTime result = dt.plusDays(3);

And the API is here, look up the API when you use it.
http://joda-time.sourceforge.net/api-release/index.html

References:
http://sillycat.iteye.com/blog/1819572
http://joda-time.sourceforge.net/userguide.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值