This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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: 32481
    
214

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


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14950
    
  26

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: 32481
    
214

Cool! Very elegant.
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 914
    
  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
 
jQuery in Action, 3rd edition