Created
July 6, 2016 13:49
-
-
Save smaznet/ff12b9fdd9e15a187794d9ebe1145fa5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner input = new Scanner(System.in); | |
System.out.print("Enter a date with yyyymm format: \n"); | |
String number1 = input.next(); | |
System.out.println(Yyyymm2mmmyy(number1)); | |
} | |
public static String Yyyymm2mmmyy(String input){ | |
String[] months=new String[]{ | |
"01", | |
"02", | |
"03", | |
"04", | |
"05", | |
"06", | |
"07", | |
"08", | |
"09", | |
"10", | |
"11", | |
"12" | |
}; | |
String[] names=new String[]{"Jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"}; | |
String iny=input.substring(0,4); | |
String inm=input.substring(4); | |
String changed="i"; | |
for(int i=0;i<names.length;i++){ | |
if(inm.equals( months[i])){ | |
return names[i]+iny.substring(2); | |
} | |
} | |
return null; | |
//return changed+iny.substring(2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment