import java.text.ParseException;

import javax.swing.text.MaskFormatter;

public class _MaskDemo
{
  public static void main( String[] args )
  {
    String mask = "##-##-####";
    String date = "12031973";

    try
    {
      MaskFormatter mf = new MaskFormatter( mask );
      mf.setValueContainsLiteralCharacters( false );
      System.out.println( mf.valueToString(date) );
    }
    catch ( ParseException e )
    {
      e.printStackTrace();
    }
    
  }
}
