Dave's Brain

Browse - Programming Tips - How can I make a nice timestamp?

Date: 2016nov17
Language: Java
Keywords: log, logging

Q.  How can I make a nice timestamp?

A.  Use SimpleDateFormat like this:

SimpleDateFormat stampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String timeStamp() { Date date = new Date(); return stampFormat.format(date); }

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.