`
sillycat
  • 浏览: 2542094 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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

 
阅读更多
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


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics