5

Basically what I need is round any date to days. For example: 2014-01-01 14:00:00 should be converted to 2014-01-01.

I was trying to achieve it using DateTimeFormatter but was not able to find a method which would return me an actual joda object but not a String.

Wild Goat
  • 3,509
  • 12
  • 46
  • 87
  • You want to truncate the date. I think this answer will help you: http://stackoverflow.com/questions/4133682/jodatime-equivalent-of-dateutils-truncate – Magnilex May 13 '14 at 09:05
  • So your input is a string (e.g. `"2014-01-01 14:00:00"`) and you want the result to be a [`LocalDate`](http://joda-time.sourceforge.net/apidocs/org/joda/time/LocalDate.html)? If not, which Joda object type did you desire? – Duncan Jones May 13 '14 at 09:09

1 Answers1

5
DateTime d = DateTime.now();
LocalDate ld = new LocalDate(d);

The local date will contain only year, month date

Poorna Subhash
  • 2,078
  • 2
  • 21
  • 28