Getting the individual digits of a number
I would suggest a third approach that extends the conversion-to-string approach: conversion to List of Character 

The benefits of this is that you can utilise Java 8 collection stream feature to perform filtering, aggregation and other functions on the elements.

for instance, your example can be expressed as such (edited following @h.j.k's comment): 

    long num = 123456789;
    String s = String.valueOf(num);
    long count = s.chars()
            .mapToObj(i -&gt; (char)i)
            .filter(ch -&gt; ch.equals('1'))
            .count();