This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Simple Joda DateTime Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Simple Joda DateTime Question" Watch "Simple Joda DateTime Question" New topic

Simple Joda DateTime Question

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196

I am creating a Joda DateTime object as follows...

I am seeing that the value of dt1 in my debugger is "2013-10-07T00:00:00.000-04:00". So I am just wondering what this "T00:00:00.000-04:00" means? I am guessing it is the time representation of my date but what time is it?

Rob Spoor

Joined: Oct 27, 2005
Posts: 20128

The value you're seeing is similar to the ISO-8601 formatting. This dictates that the date is first formatted in yyyy-MM-dd format, followed by a literal T, followed by the time and the time zone. So for your date:
  • 2013-10-07 is the date (October 7th).
  • T is the required literal.
  • 00:00:00.000 is the time with millisecond precision (midnight).
  • -04:00 is the timezone offset from UTC (4 hours before UTC).

  • SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
    How To Ask Questions How To Answer Questions
    Jesper de Jong
    Java Cowboy
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 14991

    The Joda Time library has a number of different classes for dates and times.

    DateTime is a timestamp that contains a date and a time, in a certain timezone.

    If you just want a date (without a time), use LocalDate instead of DateTime.

    Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
    I agree. Here's the link:
    subject: Simple Joda DateTime Question
    It's not a secret anymore!