Database primary key Generation tool class by fixed prefix

Source: Internet
Author: User

Package; Public classTableidgenerator {/** * Str required, shaped like SUA0000046 * beginindex required, the number of digits starting from the English character, for example SUA0000046, is starting from 3 * @param str * @param beginindex * @return*/      Public StaticString Generatorid (String str,intbeginindex) {String Leftstr=str.substring (0, beginindex);//first half English charactersString rigthtstr=str.substring (Beginindex);//first half digit character        intLen=rigthtstr.length ();//total number of digits        intRightint=integer.parseint (RIGTHTSTR) +1; String s=rightint+""; intlen1=s.length (); if(len>len1) {            inti=len-len1;  for(intj =0; J < I; J + +) {Leftstr+="0"; } leftstr+=Rightint; }Else{leftstr+=Rightint; }        returnLeftstr; }           Public Static voidMain (string[] args) {String s= Tableidgenerator.generatorid ("rw_0009",3); System. out. println (s); }    }

Database primary key Generation tool class by fixed prefix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.