Answer to Question #56511 in Java | JSP | JSF for Christine
To make a script to display only current month,day,year, or date
1
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!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment