Skip to content
Advertisement

Tag: datestamp

Generate a current datestamp in Java

What is the best way to generate a current datestamp in Java? YYYY-MM-DD:hh-mm-ss Answer 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

Advertisement