结果
上面的代码示例将产生以下结果。
shortMonth = Jan
shortMonth = Feb
shortMonth = Mar
shortMonth = Apr
shortMonth = May
shortMonth = Jun
shortMonth = Jul
shortMonth = Aug
shortMonth = Sep
shortMonth = Oct
shortMonth = Nov
shortMonth = Dec
以下是日期、时间和短月份的另一个示例示例。
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Calendar;
public class Main {
public static void main(String[] argv) throws Exception {
String str1 = "dd-MMM-yy";
Date d = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat(str1, Locale.FRENCH);
System.out.println(sdf.format(d));
sdf = new SimpleDateFormat(str1, Locale.ENGLISH);
System.out.println(sdf.format(d));
}
}