How to get the modern month name using java program?
How to get the current month name using java program? I tried different methods but none of them worked out. Any suggestion would be highly appreciated.
How to get the modern month name using java program?
How to get the current month name using java program? I tried different methods but none of them worked out. Any suggestion would be highly appreciated.
Last edited by RodríguezBrown; 01-22-2010 at 06:18 PM.
Follow the given code which is helpful for you.
import java.text.DateFormat;
import java.util.Date;
public class DateFormatExample1 {
public static void main(String[] args) {
Date n = new Date();
System.out.println(" 1. " + n.toString());
System.out.println(" 2. " + DateFormat.getInstance().format(n));
System.out.println(" 3. " + DateFormat.getTimeInstance().format(n));
System.out.println(" 4. " +
DateFormat.getDateTimeInstance().format(n));
System.out.println(" 5. " +
DateFormat.getTimeInstance(DateFormat.SHORT).forma t(n));
System.out.println(" 6. " +
DateFormat.getTimeInstance(DateFormat.MEDIUM).form at(n));
System.out.println(" 7. " +
DateFormat.getTimeInstance(DateFormat.LONG).format (n));
System.out.println(" 8. " + DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT).format(n));
System.out.println(" 9. " + DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.SHORT).format(n));
System.out.println("10. " + DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.LONG).format(n));
}
}
Bookmarks