M
Mr.javiXx
Gast
hallo,
kann mir bitte jemand helfen
ich sitze schon seit 1 woche daran und komme nicht weita
kann mir jemand sagen was ich hier falsch gemacht habe???
der erste code ging gut aba dann hatte ich probleme mit dem 2ten code!!!
Tes.java:11: cannot find symbol
symbol : class DateFormat
location: class Tes
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
^
Tes.java:11: cannot find symbol
symbol : variable DateFormat
location: class Tes
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
Tes.java:11: cannot find symbol
symbol : variable DateFormat
location: class Tes
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
^
3 errors
könnt ihr mir bitte helfenn???
kann mir bitte jemand helfen
ich sitze schon seit 1 woche daran und komme nicht weita
kann mir jemand sagen was ich hier falsch gemacht habe???
Java:
import java.util.*;
public class DateUtils{
static final int MILLS_IN_DAY = 24*60*60*1000;
public static Date getCurrentDate(){
GregorianCalendar currentDate = new GregorianCalendar();
currentDate.set(Calendar.HOUR,0);
currentDate.set(Calendar.MINUTE,0);
currentDate.set(Calendar.SECOND,0);
return currentDate.getTime();
}
public static Date createDate(int year, int month, int day){
GregorianCalendar date = new GregorianCalendar(year,month,day);
return date.getTime();
}
public static Date stripTime(Date date){
GregorianCalendar currentDate = new GregorianCalendar();
currentDate.setTime(date);
currentDate.set(Calendar.HOUR,0);
currentDate.set(Calendar.MINUTE,0);
currentDate.set(Calendar.SECOND,0);
return currentDate.getTime();
}
public static int daysDiff(Date date1, Date date2){
date1 = stripTime(date1);
date2 = stripTime(date2);
long longDate1=date1.getTime();
long longDate2=date2.getTime();
long longDiff = longDate2 - longDate1;
return (int)(longDiff/MILLS_IN_DAY);
}
}
}
dann hab ich das getestet mit:
public class Tes{
public static void main(String[] args) {
GregorianCalendar currentGC = new GregorianCalendar();
int currentYear = currentGC.get(Calendar.YEAR);
Date currentDate = DateUtils.getCurrentDate();
Date christmas = DateUtils.createDate(currentYear,Calendar.DECEMBER,25);
int daysToChristmas = DateUtils.daysDiff(currentDate, christmas);
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
String formattedDate = dateFormat.format(currentDate);
System.out.println("Today" + formattedDate);
System.out.println("There are"+daysToChristmas);
}
}
Tes.java:11: cannot find symbol
symbol : class DateFormat
location: class Tes
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
^
Tes.java:11: cannot find symbol
symbol : variable DateFormat
location: class Tes
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
Tes.java:11: cannot find symbol
symbol : variable DateFormat
location: class Tes
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);
^
3 errors
könnt ihr mir bitte helfenn???
Zuletzt bearbeitet von einem Moderator: