What is the best way to generate a current datestamp in Java?
YYYY-MM-DD:hh-mm-ss
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using the standard JDK, you will want to use java.text.SimpleDateFormat
However, if you have the option to use the Apache Commons Lang package, you can use org.apache.commons.lang.time.FastDateFormat
FastDateFormat has the benefit of being thread safe, so you can use a single instance throughout your application. It is strictly for formatting dates and does not support parsing like SimpleDateFormat does in the following example: