Tutorialspoint examples

Learn java tutorial with examples for beginners online

Convert date to string java program

Java convert date to string java example

package com.tutorialspointexamples;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateToString {
  public static void main(String args[]){
	try {
		DateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
		String dateString = df.format(new Date());
		System.out.println("Date: " + dateString);
	} catch (Exception e) {


Date: 18-Mar-2018

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status