Generating a globally unique identifier in Java

前端 未结 6 1897
广开言路
广开言路 2020-11-29 04:32

Summary: I\'m developing a persistent Java web application, and I need to make sure that all resources I persist have globally unique identifiers to prevent

6条回答
  •  猫巷女王i
    2020-11-29 04:50

    why not do like this

    String id = Long.toString(System.currentTimeMillis()) + 
        (new Random()).nextInt(1000) + 
        (new Random()).nextInt(1000);
    

提交回复
热议问题