Answer to Question #56511 in Java | JSP | JSF for Christine

Question #56511
To make a script to display only current month,day,year, or date
1
Expert's answer
2016-01-19T08:28:40-0500
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Locale;

public class DatePrinter {

public static void main(String[] args) {

GregorianCalendar calendar = new GregorianCalendar();

SimpleDateFormat format = new SimpleDateFormat("MMMM",Locale.ENGLISH);
String mounth = format.format(calendar.getTime());
System.out.println(mounth);

format = new SimpleDateFormat("EEEE",Locale.ENGLISH);
String day = format.format(calendar.getTime());
System.out.println(day);

format = new SimpleDateFormat("yyyy");
String year = format.format(calendar.getTime());
System.out.println(year);

format = new SimpleDateFormat("dd/MM/yyyy");
String date = format.format(calendar.getTime());
System.out.println(date);


}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS