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
  • 254,901
  • 44
  • 429
  • 631
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ć
  • 63,078
  • 28
  • 122
  • 148