Dm Laf

Greenhorn
+ Follow
since Mar 23, 2004
Merit badge: grant badges
For More
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 Dm Laf

"You're *NOT* asking Java to give you the Date in India. You're asking Java to give you the Date of a Calendar with a TZ of India"... Do you hear yourself what you just said?

Please stop repeating that Date has no timestamp. I think we have established that already. I am not arguing that! What I am arguing is the following piece of code

Calendar.getInstance(IndiaTZ).getTime() = Calendar.getInstance(LondonTZ).getTime() =Calendar.getInstance(CairoTZ).getTime() <--- WRONG!

It may be the same *underlying absolute moment in time* BUT 2010/12/05 04:00PM is not the same as 2010/12/04 :00AM nor 2010/12/04 03:AM. That is my argument here. That is the reason I am asking Calendar for the DETAILS of the *underlying absolute moment in time* in different TIMEZONES! Calendar is sending me a Date object, but I expect it to be modified according to the timezone. Otherwise, what is the point of supplying a timezone to the Calendar obj?


13 years ago
Thank you Mike for taking the time to answer to my question.

I totally agree with you that Date does not have a timezone, but the way I see it, if I live in Russia and I am asking Java to give me the current date in India then Calendar.getInstance(Timezone of India).getTime() should return the current time in India. Returning the local time is fundamentally incorrect. Period.

Playing with toString() methods just to get (and not output..) a time in a different timezone is just not right.

I may have to report to Oracle as an issue that require further attention.

Thank you very much for all your responses guys.
13 years ago
Thank you guys for your responses.

I think I may have been misunderstood in my original post and that is probably why every1 is giving me examples on how to output the date in different timezones.

That is NOT why I am looking an answer for. All I need to know is why Calendar.getInstance(Timezone ).getTime() ALWAYS displays my local time. I would have expected that since I am supplying a timezone, the getTime() method of the Calendar class, outputs the time for that zone.

Like I said on my second post, I have a client/server application and I need to find a way to populate fields on the client with the server calendar details. These fields (and I am not talking about plain labels or texts), accept only Calendar objects.

Thank you again for your time

PS: Darryl: " It represents a point in time, which is the same instant everywhere, whether it's dawn in New York or dusk in New Delhi." I agree. But the same instance of time in New Delhi it could be 08.00am and in Adelaide, Australia it could be 11.00am. Again, since I am supplying a timezone in the Calendar, I'd expect it would return the corresponding time.
13 years ago
Hi Kurt,

First of all, I'd like to thank you for your immediate response.

Now..What I do not understand is that if the getTime() method always displays my local time, disregarding the timezone parameter in the getInstance(Timezone tz) method, then whats the point of supplying one? Is it a bug?

I dont just need to output the date..I need a calendar object because I am working on a client/server application and several components on my client need to contain the server time. These components are setting their values based on the Calendar.getTime() method. So you see where my issue is..?

Thank you,


13 years ago
Greeting everyone!

I've got this weird issue. The following piece of code outputs my local time instead of the time of the set timezone.


What am I doing wrong? How could I get a calendar object (or a Date) with values set to the preferred timezone?
13 years ago
You probably need to include in your project's classpath all the jars which are located in your server's libs directory
I am trying to deploy a message driven bean into Ora 10g Application Server and I get this error message. I assume that there is something wrong with my ejb-jar.xml and orion-ejb-jar.xml files. Or even with the jms.xml file in the server.
ejb-jar.xml
<?xml version = '1.0' encoding = 'windows-1253'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<description>Message Driven Bean</description>
<display-name>MDB</display-name>
<ejb-name>MDB</ejb-name>
<ejb-class>MDB</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>

</message-driven-destination>
<security-identity/>
<resource-ref>
<description>Topic MDB</description>
<res-ref-name>jms/MDBTopicConnectionFactory</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor/>
</ejb-jar>

orion-ejb-jar.xml
<?xml version = '1.0' encoding = 'windows-1253'?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
<orion-ejb-jar>
<enterprise-beans>
<message-driven-deployment name="MDB"
destination-location="jms/MDBTopic"
connection-factory-location="jms/MDBTopicConnectionFactory" />
</enterprise-beans>
</orion-ejb-jar>

I have also added this code into my server's jms.xml file
<!-- Topic bindings, these topic will be bound to their respective
JNDI path for later retrieval -->
<topic-connection-factory name="MDBTopicConnectionFactory" location="jms/MDBTopicConnectionFactory"/>
<topic name="MDBTopic" location="jms/MDBTopic"/>

Thanks in advance
20 years ago
Apparently your project needs to read a file called jndi.properties in order to access your server. Now depending on the server, different contexts are developed.
If you are using JBoss, a jndi.properties file should be saved in your classes folder and it should look like this:
Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");
Greetings everyone.! Yesterday, I was trying to deploy a message driven bean to JBoss which after a lot of help, I managed to do it! But when I am trying to deploy the same bean with the same xml descriptors into Oracle 10g Application Server, it gives me this error message "No location set for Topic resource ". Would u know what I should do??
Following a copy of the ejb-jar.xml
<?xml version = '1.0' encoding = 'windows-1253'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<description>Message Driven Bean</description>
<display-name>MDB</display-name>
<ejb-name>MDB</ejb-name>
<ejb-class>MDB</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
<security-identity/>
</message-driven>
</enterprise-beans>
<assembly-descriptor/>
</ejb-jar>

Thank you
Is the subscriber using the message listener, when a message is published, to receive the message and remove it from the topic.
Will the subscriber be able to receive another message from a publisher on the same topic.
At the moment i have developed an mdb,publisher and subscriber and i receive only the first message without any listener whatsoever.
However if i add the following line: subscriber.setMessageListener(this); i get the following exception: javax.jms.JMSException: A message listener is already registered. My class implements MessageListener and onMessage method.
Any ideas?