Q:

Write a Java program to display the current date time in specific format

0

Write a Java program to display the current date time in specific format
Sample Output:

Now: 2017/06/16 08:52:03.066

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

 import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class Exercise47 {

	public static void main(String args[]) {
		SimpleDateFormat cdt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
		cdt.setCalendar(Calendar.getInstance(TimeZone.getTimeZone("GMT")));
		
		System.out.println("\nNow: "+cdt.format(System.currentTimeMillis()));
	}
}

Sample Output:

Now: 2017/06/16 08:52:03.066

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now