Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Help coderanch get a
new server
by contributing to the
fundraiser
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Java in General
Date Formatting
Tony Evans
Ranch Hand
Posts: 681
1
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I need to format todays Date and time as
Todays Date YYYYMMDD
Todays Time HHMMSS
Can someone give me an example of this or point to a web page with some good easy to follow examples.
Thanks Tony
Bernhard Jung
Greenhorn
Posts: 11
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
SimpleDateFormat
Jean-Francois Briere
Ranch Hand
Posts: 101
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
More specifically (
you should
alse read the SimpleDateFormat documentation):
Date curDateTime = new Date(); // Gets current date-time SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd"); // Creates a SimpleDateFormat object with appropriate date pattern. SimpleDateFormat sdfTime = new SimpleDateFormat("HHmmss"); // Creates a SimpleDateFormat object with appropriate time pattern. System.out.println("Todays Date " + sdfDate.format(curDateTime)); // Prints at the console the date with appropriate format. System.out.println("Todays Time " + sdfTime.format(curDateTime)); // Prints at the console the time with appropriate format.
Jim Yingst
Wanderer
Posts: 18671
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think Bernhard meant something like:
SimpleDateFormat
.
"I'm not back." - Bill Harding,
Twister
Tony Evans
Ranch Hand
Posts: 681
1
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks everyone
Tony
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Dates comparison with Calendar
Getting yesterday's date ......
How to obtain week of year for any given date
To find week of the year for any given date
Question on Creation of a Date Object
More...