Re: Cast Problem zu Obeckt
- From: "fabian_szukat@xxxxxxxxxx" <fabian.szukat@xxxxxxxxxxxxxx>
- Date: 23 Jun 2006 04:40:30 -0700
Ok dann mauikle ich dir den Code:
import java.util.Date;
import java.util.GregorianCalendar;
/**
* @author Fabian
* @version 0.3 year in four digits. return statmant as Array tage[0]=
day and
* tage[1] = month
*/
public class Kalender {
private String[] mon = new String[12];
private int[] days = new int[32];
private int[] jahre = new int[31];
public Kalender() {
Date date = new Date();
int jahr = date.getYear() + 1900;
int j = 1;
mon[0] = "Januar";
mon[1] = "Februar";
mon[2] = "März";
mon[3] = "April";
mon[4] = "Mai";
mon[5] = "Juni";
mon[6] = "Juli";
mon[7] = "August";
mon[8] = "September";
mon[9] = "Oktober";
mon[10] = "Novemer";
mon[11] = "Dezember";
/* tage */
int size = days.length - 1;
for (int i = 0; i < size; i++) {
days[i] = j;
j++;
}
for (int i = 0; i < 30; i++) {
jahre[i] = jahr;
jahr++;
}
}
/**
*
* @param jahr
* @return int[]
*/
public int[] ostersontag(int jahr) {
int[][] jahre = new int[8][4];
int[] tage = new int[2];
jahr = jahr + 1900;
int m = 0;
int n = 0;
/*
* von 1582 bis 1699
*/
jahre[0][0] = 1582;
jahre[0][1] = 1699;
jahre[0][2] = 22;
jahre[0][3] = 2;
/*
* von 1700 bis 1799
*/
jahre[1][0] = 1700;
jahre[1][1] = 1799;
jahre[1][2] = 23;
jahre[1][3] = 3;
/*
* von 1800 bis 1899
*/
jahre[2][0] = 1800;
jahre[2][1] = 1899;
jahre[2][2] = 23;
jahre[2][3] = 4;
/*
* von 1900 bis 2099
*/
jahre[3][0] = 1900;
jahre[3][1] = 2099;
jahre[3][2] = 24;
jahre[3][3] = 5;
/*
* von 2100 bis 2199
*/
jahre[4][0] = 2100;
jahre[4][1] = 2199;
jahre[4][2] = 24;
jahre[4][3] = 6;
/*
* von 2200 bis 2300
*/
jahre[5][0] = 2200;
jahre[5][1] = 2299;
jahre[5][2] = 25;
jahre[5][3] = 0;
/*
* von 2300 bis 2399
*/
jahre[6][0] = 2300;
jahre[6][1] = 2399;
jahre[6][2] = 26;
jahre[6][3] = 1;
/*
* von 2400 bis 2499
*/
jahre[7][0] = 2400;
jahre[7][1] = 2499;
jahre[7][2] = 25;
jahre[7][3] = 2;
for (int j = 0; j < jahre.length; j++) {
if (jahr <= jahre[j][0] & jahr >= jahre[j][1]) {
m = jahre[j][2];
n = jahre[j][3];
break;
}
}
int a = jahr % 19;
int b = jahr % 4;
int c = jahr % 7;
int d = ((19 * a) + m) % 30;
int e = ((2 * b) + (4 * c) + (6 * b) + n) % 7;
if (22 + d + e >= 31) {
tage[0] = d + e - 9;
tage[1] = 4;
} else {
tage[0] = 22 + d + e;
tage[1] = 3;
}
return tage;
}
/**
* @param jahr
* @return
*/
public int[] ostermontag(int jahr) {
int[] tage = ostersontag(jahr);
tage[0] = tage[0] + 1;
return tage;
}
/**
*
* @param jahr
* @return
*/
public int[] himmelsfart(int jahr) {
/* varaiben */
int zwi;
int tag = 39;
int[] tage = ostersontag(jahr);
if (tage[1] == 4) {
zwi = tage[0] - 30;
int i = tag + zwi;
int z = tage[1] + 1;
} else {
zwi = tage[0] - 31;
int i = tag + zwi;
int z = tage[1] + 1;
}
return tage;
}
/**
* @return tage;
* @param jahr
*/
public int[] karfreitag(int jahr) {
int[] tage = ostersontag(jahr);
tage[0] = tage[0] - 3;
return tage;
}
public int[] pfingsten(int jahr) {
int[] tage = himmelsfart(jahr);
if ((tage[0] + 10) > 30) {
tage[0] = tage[0] + 10;
tage[0] = tage[0] - 31;
tage[1] = tage[1] + 1;
} else {
tage[0] = tage[0] + 10;
tage[1] = tage[0] + 0;
}
return tage;
}
/**
* @param jahre
* @return
*/
public int[] pfingstmontag(int jahre) {
int[] tage = pfingsten(jahre);
tage[0] = tage[0] + 1;
return tage;
}
/**
* @return
*/
public int[] drei_köige() {
int[] tage = new int[1];
tage[0] = 6;
tage[1] = 1;
return tage;
}
/**
* @return tage[]
*/
public int[] maifeiertag() {
int[] tage = new int[1];
tage[0] = 1;
tage[1] = 5;
return tage;
}
/**
*
* @return int[]
*/
public int[] dt_eiheit() {
int[] tage = new int[1];
tage[0] = 3;
tage[1] = 10;
return tage;
}
/**
*
* @return int[]
*/
public int[] heute() {
Date date = new Date();
int[] today = new int[3];
today[0] = date.getDate();
today[1] = date.getMonth();
today[2] = date.getYear();
return today;
}
/**
*
* @return int
*/
public int erstertag_des_montats() {
Date date = new Date();
int datee = date.getDate();
date.setDate(1);
int i = date.getDate();
date.setDate(datee);
return i;
}
/**
*
* @param i
* @return tmp
*/
public String wochentag(int i) {
String[] wochenday = new String[7];
String tmp = "";
wochenday[0] = "Sonntag";
wochenday[1] = "Montag";
wochenday[2] = "Dienstag";
wochenday[3] = "Mittwoch";
wochenday[4] = "Donnerstag";
wochenday[5] = "Freitag";
wochenday[6] = "Samstag";
int size = wochenday.length - 1;
for (int j = 0; j < (wochenday.length - 1); j++) {
if (j == i) {
tmp = wochenday[j];
}
}
return tmp;
}
public int schaltjahr(int jahr) {
int i = 0;
if (jahr % 4 == 0) {
if (jahr % 100 == 0) {
if (jahr % 400 == 0) {
i = 1;
} else {
i = 0;
}
} else {
i = 1;
}
} else {
i = 0;
}
return i;
}
public String getmonatname(int monat) {
String mona = mon[monat];
return mona;
}
public int Monat(String monat) {
int monate = 0;
for (int i = 0; i < mon.length; i++) {
if (monat == mon[i]) {
monate = i + 1;
break;
}
}
return monate;
}
/**
*
* @param tage
* @return
*/
public int gettage(int tage) {
int da = days[tage];
return da;
}
/**
*
* @param arra
* @return
*/
public int getjahre(int arra) {
int i = jahre[arra];
return i;
}
/**
*
* @return
*/
public int getsizemon()
{
int i = mon.length;
return i;
}
/**
*
* @return
*/
public int getsizedays()
{
int i = days.length;
return i;
}
public int monatsdifferenz(int anfang, int ende, int anfangmonat, int
jahr)
{
int i = schaltjahr(jahr);
int tage = 0;
if(anfangmonat == 2 )
{
if (i == 1)
{
tage = 27;
}
else
{
tage = 26;
}
}
if(anfangmonat == 1 | anfangmonat == 3 | anfangmonat == 5 |
anfangmonat == 7| anfangmonat == 8 | anfangmonat == 10| anfangmonat ==
12)
{
tage = 31;
}
else
{
tage = 30;
}
int teila = tage -anfang;
int ganz = teila + ende;
ganz = ganz - 1;
return ganz;
}
/*--------------------------------------------------------------------------------*/
public int tagesdiverrentz(int von, int bis)
{
int i = bis - von;
return i;
}
/*---------------------------------------------------------------------------------*/
public int getwochentag(int day, int month, int year)
{
int jh = year / 100;
int ja = year % 100;
/*--Hilfe varabelen zum
ausrechen------------------------------------------*/
int m = (((month+1)*26)/10);
int h = (ja /4);
System.out.println("m ="+ m +", h = "+h);
int wt = (day + m +ja +h +5 - jh)%7;
System.out.println(wt);
return wt;
}
}
Dieter Sebastian schrieb:
fabian_szukat@xxxxxxxxxx wrote:
public void bisjahrebox()^^^^^^^^^^^^^
java.lang.Error: Unresolved compilation problem:^^^^^^^^
Cannot cast from int to Object
at View.jahrebox(View.java:1119)
Bist du sicher, daß du uns den richtigen Quellcode geschickt hast?
for (int i = 0; i < 30; i++) {
bisjahr.addItem((Object)kalender.getjahre(i));
Woher sollen wir wissen, wie kalender.getjahre() funktioniert?
Was ist bisjahr?
Was ist kalender?
}
p_south.add(bisjahr);
}
Wie kann man das mache dass dieses Problem nichrt mehr auf taucht.
Das können wir mit Info, die du uns gibst, nicht wissen.
Ansonsten lerne ab hier:
http://tinyurl.com/ofrkr
Gruss
Dieter
.
- Follow-Ups:
- Re: Cast Problem zu Obeckt
- From: Wanja Gayk
- Re: Cast Problem zu Obeckt
- From: Christian Schmelzer
- Re: Cast Problem zu Obeckt
- References:
- Cast Problem zu Obeckt
- From: fabian_szukat@xxxxxxxxxx
- Re: Cast Problem zu Obeckt
- From: Dieter Sebastian
- Cast Problem zu Obeckt
- Prev by Date: Re: HTTPS Verbindung *von JSP aus* öffnen
- Next by Date: Re: HTTPS Verbindung *von JSP aus* öffnen
- Previous by thread: Re: Cast Problem zu Obeckt
- Next by thread: Re: Cast Problem zu Obeckt
- Index(es):
Relevant Pages
|