Quantcast
Channel: How to get current timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss" - Stack Overflow
Browsing all 12 articles
Browse latest View live

Answer by Anuj Bansal for How to get current timestamp in string format in...

I am Using thisString timeStamp = new SimpleDateFormat("dd/MM/yyyy_HH:mm:ss").format(Calendar.getInstance().getTime());System.out.println(timeStamp);

View Article



Answer by gzc for How to get current timestamp in string format in Java?...

Use modern java.time classes if you use java 8 or newer.String s = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());Basil Bourque's answer is pretty good. But it's too...

View Article

Answer by Phoenix for How to get current timestamp in string format in Java?...

You can use the following:new java.sql.Timestamp(System.currentTimeMillis()).getTime()Result:1539594988651

View Article

Image may be NSFW.
Clik here to view.

Answer by Basil Bourque for How to get current timestamp in string format in...

tl;drUse only modern java.time classes. Never use the terrible legacy classes such as SimpleDateFormat, Date, or java.sql.Timestamp.ZonedDateTime // Represent a moment as perceived in the wall-clock...

View Article

Answer by user3144836 for How to get current timestamp in string format in...

A more appropriate approach is to specify a Locale region as a parameter in the constructor. The example below uses a US Locale region. Date formatting is locale-sensitive and uses the Locale to tailor...

View Article


Answer by Kakarot for How to get current timestamp in string format in Java?...

You can make use of java.util.Date instead of Timestamp :String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());

View Article

Answer by dimoniy for How to get current timestamp in string format in Java?...

Use java.util.Date class instead of Timestamp.String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());This will get you the current date in the format specified.

View Article

Answer by jmj for How to get current timestamp in string format in Java?...

Replace new Timestamp();withnew java.util.Date()because there is no default constructor for Timestamp, or you can do it with the method:new Timestamp(System.currentTimeMillis());

View Article


How to get current timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss"

How to get timestamp in string format in Java? "yyyy.MM.dd.HH.mm.ss"String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Timestamp());This is what I have, but Timestamp() requires...

View Article


--- Article Not Found! ---

*** *** *** RSSing Note: Article is missing! We don't know where we put it!!. *** ***

View Article

Answer by Sandun Susantha for How to get current timestamp in string format...

Use the following strategy.import java.sql.Timestamp;Timestamp today = new Timestamp(System.currentTimeMillis())

View Article

Answer by BrianKeys for How to get current timestamp in string format in...

java.timeThose java.util.Date answers at the top need to go. Here's some code I wrote that deals with different formats. It's also easier to go with a working example:package...

View Article
Browsing all 12 articles
Browse latest View live




Latest Images