Here you go,
Program:
public class SecondPrime {
public static void main(String[] args) {
int n=58047;
boolean primeSecond;
while (n > 9)
{
n%=10000;
n/=1000;
}
if( (n==2)||(n==3) || (n==5)|| (n==7) )
{
primeSecond=true;
}
else
primeSecond = false;
System.out.println("\nPrime Second is: "+primeSecond);
}
}