Advertisement
Guest User

Untitled

a guest
May 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.81 KB | None | 0 0
  1. public class Main
  2. {
  3.   static int monat( final String text0 )
  4.   {
  5.     final String text = text0.trim();
  6.  
  7.     final int pos = text.indexOf( '-', 1 );
  8.  
  9.     final int pos1 = text.indexOf
  10.     ( '-', pos + 1 );
  11.  
  12.     final String monat =
  13.     text.substring( pos + 1, pos1 );
  14.  
  15.     return Integer.valueOf( monat ); }
  16.  
  17.   public static void main( String[] args )  
  18.   {
  19.     System.out.println
  20.     ( monat( "2010-8-1" ) );
  21.  
  22.     System.out.println
  23.     ( monat( "333-8-1" ) );
  24.  
  25.     System.out.println
  26.     ( monat( "-333-8-1" ) );
  27.  
  28.     System.out.println
  29.     ( monat( " 2010-8-1 " ) );
  30.  
  31.     System.out.println
  32.     ( monat( " 333-8-1 " ) );
  33.  
  34.     System.out.println
  35.     ( monat( " -333-8-1 " ) );
  36.  
  37.     System.out.println
  38.     ( monat( "1-8-1" ) );
  39.  
  40.     System.out.println
  41.     ( monat( "-1-8-1" ) );
  42.  
  43.  
  44.     }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement