Commonly face by developer for getting month name from month number.
String monthyearinNo="03-2015";
String month=null;
String monthName = monthyearinNo.split("-")[0];
String yearName = monthyearinNo.split("-")[1];
DateFormatSymbols dfs = new DateFormatSymbols();
String[] months = dfs.getMonths();
month = months[Integer.valueOf(monthName)-1];
String inName=month+"-"+yearName;
System.out.println("Result : "+inName); //Result : March-2015
String monthyearinNo="03-2015";
String month=null;
String monthName = monthyearinNo.split("-")[0];
String yearName = monthyearinNo.split("-")[1];
DateFormatSymbols dfs = new DateFormatSymbols();
String[] months = dfs.getMonths();
month = months[Integer.valueOf(monthName)-1];
String inName=month+"-"+yearName;
System.out.println("Result : "+inName); //Result : March-2015
No comments:
Post a Comment