Results 1 to 1 of 1
Thread: Formatting time and date
-
Formatting time and date
Java Code:import java.util.*; public class TimeDateFormat { public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); // Display standard 12-hour time format. fmt.format("%tr", cal); System.out.println(fmt); // Display complete time and date information. fmt = new Formatter(); fmt.format("%tc", cal); System.out.println(fmt); // Display just hour and minute. fmt = new Formatter(); fmt.format("%tl:%tM", cal, cal); System.out.println(fmt); // Display month by name and number. fmt = new Formatter(); fmt.format("%tB %tb %tm", cal, cal, cal); System.out.println(fmt); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
Date/Time Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-14-2008, 09:34 AM -
File creating date/time
By bugger in forum New To JavaReplies: 1Last Post: 11-11-2007, 07:43 PM -
Time and Date in Java
By java_fun2007 in forum New To JavaReplies: 4Last Post: 11-06-2007, 07:25 PM -
how to get the current date and time
By valery in forum New To JavaReplies: 1Last Post: 08-03-2007, 06:05 PM -
Formatting the date
By yuchuang in forum New To JavaReplies: 5Last Post: 05-07-2007, 06:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks