diff --git a/SimpleDateFormat.java b/SimpleDateFormat.java new file mode 100644 index 00000000..02de9834 --- /dev/null +++ b/SimpleDateFormat.java @@ -0,0 +1,12 @@ +import java.text.SimpleDateFormat; +import java.util.Date; + +public class DateFormatExample { + public static void main(String[] args) { + Date currentDate = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String formattedDate = dateFormat.format(currentDate); + System.out.println("Current Date and Time: " + formattedDate); + } +}