mojtaba_java
یک شنبه 11 فروردین 1387, 18:27 عصر
با سلام خدمت اساتید ارجمند
عید همه مبارک
من می خواهم تاریخ شمسی را در یک textbox نشان دهم اگر ممکن است مشکلات کد زیر را بگویید.
یا اگر کد بهتری برای تبدیل سراغ دارید بگویید.
با تشکر
import java.util.*;
import java.text.*;
import java.util.Date;
public class Tarekh {
static public String Tarekh() {
String dayName[]={ "sh","1k","2s","3s","4s","5s","jome"} ;
int monName[] = { 10,11,12,1,2,3,4,5,6,7,8,9};
int mm,mr,ii;
String rr;
Date now = new Date();
rr=dayName[now.getDate()];
if (now.getMonth() <= 1 )
{
ii=now.getYear()-622;
} else {
if ( now.getDate() <= 21 && now.getMonth() == 2)
{ ii=now.getYear()-622;
} else {
ii=now.getYear()-621;
}
}
if ( now.getMonth() == 6 || now.getMonth() == 7 || now.getMonth() == 8 || now.getMonth() == 9)
{
if ( now.getDate() <=22 )
{
mm=monName[now.getMonth()] ;
} else {mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 4 || now.getMonth() == 5 || now.getMonth() == 10 )
{
if ( now.getDate() <=21 ) { mm=monName[now.getMonth()] ;
} else {mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 0 || now.getMonth() == 2 || now.getMonth() == 3 )
{
if ( now.getDate() <=20 ) { mm=monName[now.getMonth()];
} else { mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 1) { if ( now.getDate() <=19 )
{
mm=monName[now.getMonth()] ;
} else { mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 11) { if ( now.getDate() <=21 )
{
mm=monName[now.getMonth()];
} else { mm=monName[now.getMonth()-11] ;
}
}
if ( now.getMonth() == 2 || now.getMonth() == 3 || now.getMonth() == 0 )
{
if ( now.getDate() <=20 ) {mr=now.getDate()+10;
} else { mr=now.getDate()+10-30 ;
}
}
if ( now.getMonth() == 4 || now.getMonth() == 5 ){ if ( now.getDate() <=21 )
{
mr=now.getDate()+10;
} else { mr=now.getDate()+10-31;
}
}
if ( now.getMonth() == 6 || now.getMonth() == 7 || now.getMonth() == 8 )
{
if ( now.getDate() <=21 ) { mr=now.getDate()+9;
} else { mr=now.getDate()+9-31 ;
}
}
if ( now.getMonth() == 10 || now.getMonth() == 11)
{
if ( now.getDate() <=21 ) { mr=now.getDate()+9 ;
} else { mr=now.getDate()+9-30 ;
}
}
if ( now.getMonth() == 9){ if ( now.getDate() <=22 )
{ mr=now.getDate()+8;
} else { mr=now.getDate()+8-30;
}
}
if ( now.getMonth() == 1 ){ if ( now.getDate() <=20 )
{ mr=now.getDate()+11;
} else { mr=now.getDate()+11-30 ;
}
}
return( rr + "/" + mr + "/" + mm + "/" + ii );
}
}
عید همه مبارک
من می خواهم تاریخ شمسی را در یک textbox نشان دهم اگر ممکن است مشکلات کد زیر را بگویید.
یا اگر کد بهتری برای تبدیل سراغ دارید بگویید.
با تشکر
import java.util.*;
import java.text.*;
import java.util.Date;
public class Tarekh {
static public String Tarekh() {
String dayName[]={ "sh","1k","2s","3s","4s","5s","jome"} ;
int monName[] = { 10,11,12,1,2,3,4,5,6,7,8,9};
int mm,mr,ii;
String rr;
Date now = new Date();
rr=dayName[now.getDate()];
if (now.getMonth() <= 1 )
{
ii=now.getYear()-622;
} else {
if ( now.getDate() <= 21 && now.getMonth() == 2)
{ ii=now.getYear()-622;
} else {
ii=now.getYear()-621;
}
}
if ( now.getMonth() == 6 || now.getMonth() == 7 || now.getMonth() == 8 || now.getMonth() == 9)
{
if ( now.getDate() <=22 )
{
mm=monName[now.getMonth()] ;
} else {mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 4 || now.getMonth() == 5 || now.getMonth() == 10 )
{
if ( now.getDate() <=21 ) { mm=monName[now.getMonth()] ;
} else {mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 0 || now.getMonth() == 2 || now.getMonth() == 3 )
{
if ( now.getDate() <=20 ) { mm=monName[now.getMonth()];
} else { mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 1) { if ( now.getDate() <=19 )
{
mm=monName[now.getMonth()] ;
} else { mm=monName[now.getMonth()+1];
}
}
if ( now.getMonth() == 11) { if ( now.getDate() <=21 )
{
mm=monName[now.getMonth()];
} else { mm=monName[now.getMonth()-11] ;
}
}
if ( now.getMonth() == 2 || now.getMonth() == 3 || now.getMonth() == 0 )
{
if ( now.getDate() <=20 ) {mr=now.getDate()+10;
} else { mr=now.getDate()+10-30 ;
}
}
if ( now.getMonth() == 4 || now.getMonth() == 5 ){ if ( now.getDate() <=21 )
{
mr=now.getDate()+10;
} else { mr=now.getDate()+10-31;
}
}
if ( now.getMonth() == 6 || now.getMonth() == 7 || now.getMonth() == 8 )
{
if ( now.getDate() <=21 ) { mr=now.getDate()+9;
} else { mr=now.getDate()+9-31 ;
}
}
if ( now.getMonth() == 10 || now.getMonth() == 11)
{
if ( now.getDate() <=21 ) { mr=now.getDate()+9 ;
} else { mr=now.getDate()+9-30 ;
}
}
if ( now.getMonth() == 9){ if ( now.getDate() <=22 )
{ mr=now.getDate()+8;
} else { mr=now.getDate()+8-30;
}
}
if ( now.getMonth() == 1 ){ if ( now.getDate() <=20 )
{ mr=now.getDate()+11;
} else { mr=now.getDate()+11-30 ;
}
}
return( rr + "/" + mr + "/" + mm + "/" + ii );
}
}