wood burning stoves 2.0*
The moose likes Java in General and the fly likes Strange Age output using Joda time? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Strange Age output using Joda time?" Watch "Strange Age output using Joda time?" New topic
Author

Strange Age output using Joda time?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590

I've got
Age = P20Y
What do the 'P' and 'Y' stand for?
Thanks
Jack
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Jack Luk wrote:
I've got
Age = P20Y
What do the 'P' and 'Y' stand for?
Thanks
Jack


Sorry, I know now year.getYear()
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The API documentation of org.joda.time.Years.toString() answers your question: it returns the period as a string in ISO 8601 format, a standard format for representing dates, times, periods, etc.

"P20Y" in this format means a period of 20 years.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Stephen Colebourne
Greenhorn

Joined: Nov 07, 2004
Posts: 4
Please use LocalDate, not DateMidnight. DateMidnight does not work well in some countries where midnight does not exist once a year due to daylight savings.

In addition, LocalDate has dedicated methods fromDateFields() and fromCalendarFields() to convert from java.util.Date and Calendar.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Strange Age output using Joda time?
 
Similar Threads
parsing date as a string
Help with DateFormat!?
Date; Previous date, Calendar; Gregorian
problem in incrementing date
GregorianCalendar