Here you can find the source of formatDateTime(Date dateTime)
Parameter | Description |
---|---|
dateTime | The date/time |
@Deprecated public static String formatDateTime(Date dateTime)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.Calendar; import java.util.Date; public class Main { /**/* w ww. j a v a2 s . c o m*/ * A formatter for generating date/time strings. The output format is {@code YYYY-MM-DD HH:mm:ss}. */ @Deprecated private static SimpleDateFormat dateTimeFormatter = null; /** * For formatting LocalDateTime - dates and parsing date time strings */ private static java.time.format.DateTimeFormatter displayDateTimeFormatter = null; /** * Format a date/time to YYYY-MM-dd HH:mm:ss format * @param dateTime The date/time * @return The formatted date/time */ @Deprecated public static String formatDateTime(Date dateTime) { return dateTimeFormatter.format(dateTime); } /** * Format a date/time to YYYY-MM-dd HH:mm:ss format * @param dateTime The date/time * @return The formatted date/time */ public static String formatDateTime(LocalDateTime dateTime) { return displayDateTimeFormatter.format(dateTime); } /** * Format a date/time to YYYY-MM-dd HH:mm:ss format * @param dateTime The date/time * @return The formatted date/time */ @Deprecated public static String formatDateTime(Calendar dateTime) { return formatDateTime(dateTime.getTime()); } }