how to write to csv with a leading zero?

前端 未结 6 1332
北海茫月
北海茫月 2020-12-21 11:47

I wish to write to a CSV file some data. One of the column that I input the information is in the form of an integer with leading zeros, example: 0000000013.

For so

6条回答
  •  太阳男子
    2020-12-21 12:07

    Try:

    String.format("%08d", 13)
    

    Note the 0 in the format string, that tells Java to prefix the number with zeroes up to the length indicated in the field (8 in this case).

提交回复
热议问题