我正在尝试打印日期,但它不能以我需要的格式工作
import java.util.Scanner;
import java.util.Calendar;
public class MartinezC001PA2
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);//for user input
Calendar dateTime = Calendar.getInstance();//to get date and time
String userName = "";
String stockStatus = String.format("\n\nSTOCK PURCHASES FOR %S \nAS OF %1$TA, %1$TB %1$Td, %1$TY", userName, dateTime);
System.out.print(stockStatus);
}//END MAIN
}
答案 0 :(得分:-1)
DateFormat dateFormat = new SimpleDateFormat(“yyyy / MM / dd HH:mm:ss”);
日历cal = Calendar.getInstance();
的System.out.println(dateFormat.format(cal.getTime()));