Hi all, I want to create a autogenerated number with customized. It should have 7 numbers long. The first 2 digits should be like 08-- it may changes over the year.. and the next 1 digit --- 1 or 2 depends on the checkbox selection and the last four digits should be autogenerated.. Any help..
Should it remain unique among JVMs as well? And if you restart the JVM?
If so, you will have to store the last created unique part somewhere - in a file, a database, or the Windows registry (using java.util.Preference for instance). Because even classes like UUID will not create unique numbers among JVMs.
That would create random Strings, Sunil, but it wouldn't sort out Rob's problem about uniqueness. I would go for Rob's text file solution as being the simplest and possibly giving more portability than using the Registry.