LibreOffice、sprintf()

左に 0 を入れて、四桁にする

=TEXT(A1;"0000")