do we have any function in j2me so that we can validate the date and can say whether the date obtained is future date or past date from current date.
thanks and regards
Arunesh
do we have any function in j2me so that we can validate the date and can say whether the date obtained is future date or past date from current date.
thanks and regards
Arunesh
check this FN wiki which have date and time example.
http://wiki.forum.nokia.com/index.ph...ime_in_Java_ME
-------------------------------------
Thanks & Regards
Ram
Symbian OS 9.2/9.3,S60 3rd FP1/FP2,Carbide.c++v2.0
this is not what i want , i want to compare if 5 dec 2010(for eample) to future date or past date.
thanks and regards
Arunesh
This is the function i have made to compare if the given date is of future or not , argument passed to the method is value of dateField tokenized on space character .
argument passed to the function is of the form ....
String dat = dateField.getDate().toString();
StringTokenizer tokenizer = new StringTokenizer(dat, " ");
String[] date_v = tokenizer.toArray();
boolean value = validate_date(date_v);
the body of validate_date() function is given below , i have elaborated every step hence it looks big.
private boolean validate_date(String[] date_validate) {
int index_v = 0,index_c = 0;
String[] month = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
String d_v1 = date_validate[2];
int d_v = Integer.parseInt(d_v1);
String day_v = date_validate[0];
String month_v = date_validate[1];
String year_v1 = date_validate[5];
int year_v = Integer.parseInt(year_v1);
System.out.println("Date to be validated = "+d_v);
System.out.println("Day of the week to be validated = "+day_v);
System.out.println("month to be validated = "+month_v);
System.out.println("year to be validated = "+year_v);
// current date strings
Date d1 = new Date();
System.out.println(d1);
String d = d1.toString();
StringTokenizer tokenizer = new StringTokenizer(d, " ");
String[] date_v = tokenizer.toArray();
String d_c1 = date_v[2];
int d_c = Integer.parseInt(d_c1);
String day_c = date_v[0];
String month_c = date_v[1];
String year_c1 = date_v[5];
int year_c = Integer.parseInt(year_c1);
System.out.println("current date = "+d_c);
System.out.println("current month= "+month_c);
System.out.println("current year = "+year_c);
for(int i = 0; i<= month.length-1;i++)
{
if(month_v.equals(month[i]))
{
index_v = i;
index_v = index_v+1;
System.out.println("number of given the month to be validated = "+index_v);
}
if(month_c.equals(month[i]))
{
index_c = i;
index_c = index_c+1;
System.out.println("number of the current month to be validated = "+index_c);
}
}
System.out.println( "year = "+year_v+"date = "+d_v+"month number = "+index_v);
System.out.println( "current year = "+year_c+"current date = "+d_c+"current month number = "+index_c);
if(year_v >= year_c)
{
if(index_v >= index_c)
{
if(d_v >= d_c)
{
return true;
}
else if((month_v.equals(month_c))&&(year_c == year_v))
{
return false;
}
else
return true;
}
else
return false;
}
else
return false;
}
Hello Arunesh,
Here is one more alternative for your problem & solution.
Regards,
Dinanath
It's a matter of attitude.
Dear qi210xi,
What is the significance of your answer to this problem?
You pasted the same thing for another threads also?
If you want to post News/Announcement post here
Regards,
Dinanath
It's a matter of attitude.