How can I convert a java.util.Date
to String
using
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(\"yyyy-MM-dd\'T\'H
You can use the joda time formatter class:
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
# conflict with import java.time.format.DateTimeFormatter;
final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss")
.withZone(DateTimeZone.UTC);
System.out.println(DateTime.now().toString(formatter));