1

I am using java.util.concurrent.atomic.AtomicLong class to generate sequence numbers for id generation. I need to start this number from 1 each day what are the available logic, methods which I can use?

Keith Thompson
  • 242,098
  • 41
  • 402
  • 602
andare
  • 21
  • 6

1 Answers1

3

Here's an answer on how to get the beginning of a day using Joda Time. Then use the method AtomicLong#set(long) to reset the value.

Community
  • 1
  • 1
Boris Pavlović
  • 60,971
  • 26
  • 119
  • 144