With java.text.DateFormat, it\'s possible to build a date formatter with a date and a time style :
DateFormat df = getDateTimeInstance(DateFormat.SHORT, DateForm
There's a bunch of standard Date and Time formats built right into JodaTime.
Here's an example of one that I use:
DateTime dateTime = DateTime.now(DateTimeZone.UTC);
String formattedDateTime = dateTime.toString(DateTimeFormat.fullDateTime());
Notice the DateTimeFormat.fullDateTime()
.
Some other options for this include:
fullTime()
fullDate()
shortDateTime()
forStyle("MS")
Indicates a Medium Date and a Short Time.forStyle("S-")
Indicates a Short Date and No Time.http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html#forStyle(java.lang.String)
Cheers,
JP
Use DateTimeFormat.forPattern() with a pattern that does what you want.
For instance, DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss");