Real Java problems face during development, laboratory, practical, course assignment about programming in java
Tuesday, 20 October 2015
Converting Month Number to Month Name In Java[Problem face during development]
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
Subscribe to:
Comments (Atom)