Write a Java program to display the current date time in specific formatSample Output:
Now: 2017/06/16 08:52:03.066
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:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer