Frage

I'm working with variable integer lengths. For each I need to simply have the rightmost two numbers. e.g:

3938   = 38
787028 = 28
83883  = 83

The other numbers don't matter, I just need the two rightmost integer. Also, I'm working under the assumption that some numbers will be single digit. For these numbers, I will need to pad them with an extra left zero. e.g:

8 = 08
2 = 02 

Thanks

War es hilfreich?

Lösung

int foo = 3938;
int modulo = foo % 100;
String formatted = String.format("%02d", modulo);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top