Click here to watch on Youtube: 
https://www.youtube.com/watch?v=9vnN2dehJQ4&list=UUhwKlOVR041tngjerWxVccw
DateFormatDemo.java
Output:
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/DateFormatDemo_getDateTimeInstance.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/DateFormatDemo_getDateTimeInstance
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/80d90bcf5505788c0f100e330fb6b354d3132ddb/Java_2019/DateFormatDemo_getDateTimeInstance/?at=master
See also:
All JavaEE Videos Playlist 
All JavaEE Videos 
All JAVA EE Links 
Spring Tutorial 
Servlets Tutorial 
All Design Patterns Links 
JDBC Tutorial 
Java Collection Framework Tutorial 
JAVA Tutorial 
Kids Tutorial 
Cooking Tutorial 
https://www.youtube.com/watch?v=9vnN2dehJQ4&list=UUhwKlOVR041tngjerWxVccw
DateFormatDemo.java
import java.text.DateFormat;
import java.util.Date;
public class DateFormatDemo
{
public static void main(String[] args)
{
Date currentDate = new Date();
System.out.println("Current Date = " + currentDate);
/*
* Returns:
*
* a date/time formatter with the default formatting style for
* the default FORMAT locale.
*/
DateFormat dateFormat = DateFormat.getDateTimeInstance();
/*
* Parameters:
*
* date - the time value to be formatted into a date/time
* string.
*
* Returns:
*
* the formatted date/time string.
*/
String dateToStr = dateFormat.format(currentDate);
System.out.println("Formatted Date = " + dateToStr);
}
}
import java.util.Date;
public class DateFormatDemo
{
public static void main(String[] args)
{
Date currentDate = new Date();
System.out.println("Current Date = " + currentDate);
/*
* Returns:
*
* a date/time formatter with the default formatting style for
* the default FORMAT locale.
*/
DateFormat dateFormat = DateFormat.getDateTimeInstance();
/*
* Parameters:
*
* date - the time value to be formatted into a date/time
* string.
*
* Returns:
*
* the formatted date/time string.
*/
String dateToStr = dateFormat.format(currentDate);
System.out.println("Formatted Date = " + dateToStr);
}
}
Output:
Current Date = Fri Dec 28 07:54:15 IST 2018
Formatted Date = Dec 28, 2018 7:54:15 AM
Formatted Date = Dec 28, 2018 7:54:15 AM
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/DateFormatDemo_getDateTimeInstance.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/DateFormatDemo_getDateTimeInstance
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/80d90bcf5505788c0f100e330fb6b354d3132ddb/Java_2019/DateFormatDemo_getDateTimeInstance/?at=master
See also:
 


 
No comments:
Post a Comment