抱歉,我对此很陌生。
this is from another class
private String name;
private String code;
private GregorianCalendar startDateTime;
private GregorianCalendar endDateTime;
this is for main
CourseDetail []c1={new course("Java","AACS 2083",
new GregorianCalendar(2015,06,20,14,00),new GregorianCalendar(2015,06,21,15,00))};
我接近答案吗?
请问如何使用上面的方法将日期传递给GregorianCalendar? 抱歉这个虚假的问题...
答案 0 :(得分:1)
您可以直接使用util date
到GregorianCalendar
Date date = new Date();
GregorianCalendar gregoriancalendar = new GregorianCalendar();
gregoriancalendar.setTime(date);
直接设定日期
GregorianCalendar gc = new GregorianCalendar();
gc.set(GregorianCalendar.YEAR, 2015);
gc.set(GregorianCalendar.MONTH, 7);
gc.set(GregorianCalendar.DATE, 23);
构建者link
public GregorianCalendar(int year,
int month,
int dayOfMonth)
public GregorianCalendar(int year,
int month,
int dayOfMonth,
int hourOfDay,
int minute)
实施例
GregorianCalendar calendar=new GregorianCalendar(2015, 6, 23,23, 12);
答案 1 :(得分:0)
您创建一个GregorianCalendar的新对象,然后设置日期:
GregorianCalendar gc = new GregorianCalendar();
gc.set(GregorianCalendar.YEAR, 2015);
gc.set(GregorianCalendar.MONTH, 4);
gc.set(GregorianCalendar.DATE, 20);
答案 2 :(得分:0)
CourseDetail []c1={new Course("Java","AACS 2083",new GregorianCalendar(2015,06,20,14,00),new GregorianCalendar(2015,06,21,15,00))};
哦,最后,我只知道我可以通过这种形式的日期。大家好!