aspose file tools*
The moose likes Blog around the Campfire and the fly likes java 8 dates and functional programming to write a timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Other » Blog around the Campfire
Bookmark "java 8 dates and functional programming to write a timer" Watch "java 8 dates and functional programming to write a timer" New topic
Author

java 8 dates and functional programming to write a timer

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

A question in the forum got me to write a timer. This was my first time instinctively doing so in Java 8. The result made for a nice blog post


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14270
    
  21

It reminds me of something similar I wrote in Scala.

Scala has a nicer syntax than Java to do this. With this method, you can just wrap the code you want to time in a time { ... } block:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Cool! Very elegant.
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 650
    
  11
We can combine the two, like in


Greetz,
Piet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java 8 dates and functional programming to write a timer