In this section, you will learn to convert a date into string type. The java.util package provides the functionality to convert it.
Convert Date to String
In this section, you will learn to convert a date into string type. The java.util package provides the functionality to convert it.
Description of program:
This program helps you to convert the date into a string type. Firstly, you need to pass a date in the parse() method which is invoked through the DateFormat object . The format() method converts the date into a string. This method is defined as final in the DateFormat class. This is used to format a Date into a date/time string. The parameter passed is as date/time and it returns a string.
Here is the code of program:
import java.util.*;
|
Output of this program:
C:\date>javac DateToString.java C:\date>java DateToString Today is 11-Jun-07 |