Simple Date Format Function in Java

Date Format Function in Java

The below function written in Java is used to format the date in alike order. you can customize the date order on your wish by changing the date format order. For example, MM/dd/yyyy will display the month first, date second and the year at third by using the / separator. Ordering MM, dd and yyyy in different combination let you customize your date display order

Java Code to Date Format

import java.text.SimpleDateFormat;

import java.util.Date;

public class JavaSimpleDateFormatExample{

public static void main(String args[]){

Date date = new Date();

String DATE_FORMAT = "MM/dd/yyyy";

SimpleDateFormat tdate = new SimpleDateFormat(DATE_FORMAT);

System.out.println("Today is " + tdate.format(date) );



Related Topic How to Get Current Date in Java
Javascript Date Object Constructor with Examples
Date Time functions Mysql
What is difference between Custom JSP Tags and Beans
PHP UNIX Timestamp of Date and Time Functions
Java 2011   Privacy Policy  Terms of Service  Feedback