• Post Reply Bookmark Topic Watch Topic
  • New Topic

help me for package date  RSS feed

 
adam harris
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



i have a problem for insert value of date..what data type for data in line 36
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam, you shouldn't be using the old crummy Date class. It's difficult to understand, and easy to use wrongly. Instead, Java 8 has the awesome new java.time.* package.

Instead of juggling with dates and times, you can just use java.time.Instant (for measuring a moment in time) and java.time.Duration (for a sampling duration). I also recommend that every sample has a starting time regardless of whether it is the same as the previous sample's end time.

You can use Instant.now() to get your start and end times, and Duration.between() to get the sample durations.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, the classes Vector and Enumeration are old, legacy classes which you shouldn't use anymore - use ArrayList and Iterator instead.
 
adam harris
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where i should replace "You can use Instant.now() to get your start and end times, and Duration.between() to get the sample durations"
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your DataSample could look like this:

Now, you could use it like this:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!