standart implementation twitter's snowflake id generation
to add dependency append to your build.gradle file:
repositories {
maven{
url 'https://maven.pkg.github.com/teheidoma/snowflake'
}
}
and then
implementation("com.teheidoma:snowflake:1.0")