Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

raj baig

Ranch Hand
+ Follow
since Jul 11, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by raj baig

Hi All,

I am trying to optimize my code,can you tell me which is the best way of
doing

I am calling a method of a class more no of times in my code which
returns me a object





1. A a=b.getAObject();
a.getId();
2. new B().getAObject().getId()

here if i have to call getId method more times is it better to
once A object and using a ref call method.
or
instead of creating object directly call : new B().getAObject().getId()


Thanks in Advance
Raj
13 years ago
Hi ,

Just Look At The Code




See if getValue() method return true then i want to set the value "true"
to setValue() method.

But it is giving exception like not a statement after ?:

when the condition becomes true i want to set the
value to setVAlue method.

Can you correct me.

Thanks in Advance,
Raj.
13 years ago
Hi ,

I want to display starting date and ending date of weeks in a month
i.e. this month(may) :
week starting date monday : 7
week ending date saturday : 12


can you tell me how to get it.
i am using calendar but need some help.

Thanks in Advance,
Raj.
13 years ago
Hi Jesper Young

The format method will return a string. But i want the string as date object.

because i have to set the date object to a java bean ,this date object
contains the format dd-mm-yyyy to store in db as db take the format
dd-mm-yyyy.

private date.
public setDate(java.sql.Date date){
thid.date=date
}

Awaiting for reply,
Raj.
13 years ago
Hi,
i want to convert a string in sql or util date object to insert in oracle database but in the same format .

String date="10-04-2006";
SimpleDateFormat df1=new SimpleDateFormat("dd-MM-yyyy");
Date d=df1.parse(date);
java.sql.Date sqlDate = new java.sql.Date ( t ) ;
System.out.println("date:"+sqlDate);


Here originally my string format is : dd-mm-yy 10-04-2006
Sql date returns after parsing : yyyy-mm-dd. 2006-04-10


Please tell me how to convert it.

----
Raj.
13 years ago
Hi,
I have a string contaings date.
String date="10-04-2007";
now i am converting it into sql date using simpledateformat's parse method
which returns me sql date but in different format.
ie. 2006-01-10

But i want the returned date objected should follow same format like
10-04-2007.

Can you assist me.

thangs in advance
raj.
13 years ago
sql
Thanks All
sql
Hi,
Userid column is already a primary key column.
sql
Hi,
In my database i have user table contains user_id,password,email.
To insert a new row i am checking for the email.if email already exists
i am generating error message the email already exist.
Here my problem is i am interacting db twice.
1.select query returns true if user exists
2.insert data if select query returns false.

But i want this should happen in a single query.
Can you tell me how to do it.


Thanks in Advance,
Raj.
HI Ulf

this is doing fine.

Method[] theMethods=class.getDeclaredMethods();


Thanks:
Raj
13 years ago
hi ulf,
i dis same as you said. It is calling my methods + Object class methods.
But i don't want the object class methods to execute. How can i restrict.

Thanks.
13 years ago
HI All,
How can i call only user defined methods only not the Object class methods.
when i call invoke method it is calling my class methods as well Object
class methods.
How can i restrict Object class methods.

Thank you for your reply.
13 years ago
Hi Rahul,
The invoke method expects two objects.
Then how call.
13 years ago
Hi Rahul,
To call invoke() , it expects two objects to pass.
Then how call.
13 years ago
hi,
i have a class with two methods

public void metOne(){
System.out.println(" Hello ");
}

public String metTwo(){
return " Hai ";
}

in another class i am invoking the two methods



It is giving me exception:

java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at TestReflect.showMethods(TestReflect.java:22)
at TestReflect.main(TestReflect.java:7)


can you tell me the mistake.

Thanks in advance,
raj.
13 years ago