String s="yourstring";
boolean flag = true;
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)=='-')
{
System.out.println(s.substring(0,i));
System.out.println(s.substring(i+1));
flag= false;
}
}
if(flag)
{
System.out.println("The string is not in proper format");
}