J john

Greenhorn
+ Follow
since May 28, 2013
J likes ...
Java
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 J john

Richard, I have tried that already. but not working.

Ivan, Thanks for the suggestion. But the issue i am talking about the jvm. Why JVM not taking system time. How can make jvm time uses system time by NOT using anything via code. Hope you understood what i meant.

regards
John
6 years ago
Could you please suggest a solution?
6 years ago
No. I am not passing any VM parameters to set the time zone. I can not pass timezone in VM parameter, since it will fail when daylight saving changes. Correct me if am wrong..
6 years ago
When I executing 'date' command in the terminal it display the result like this

[fuel@H00170a ~]$ date
Wed Aug 21 05:19:59 CDT 2013



This is the code am using in Java file

System.out.println( "TIME-ZONE:" + TimeZone.getDefault() );
System.out.println("Date in Java " + new Date( ));


Output comes like below:

TIME-ZONE:sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
Date in Java Wed Aug 21 10:59:48 GMT 2013.


System date shows time as Wed Aug 21 05:19:59 CDT 2013 where as the time in java is Wed Aug 21 10:59:48 GMT 2013.

What needs to be done for java to time same as system date ie, Wed Aug 21 05:19:59 CDT 2013.

Some more information related to my environment.
The java application is running on a dump client. When the dump client boots up, it download OS, jre and all related software required to run the application from a Linux server machine using tftboot. The dump client does not have a connectivity to time server. So we use a program which will fetch time from the server machine and set that time to local machine before the tftboot installs jre on the client machine. Why we setting the time from server machine is because the dump client was initializing with wrong time and date. The year in the date was 2001.
6 years ago
Hi,

I am running java application in Linux box. The timezone of the system is set to CDT (ie. when I issue the command 'date' in terminal it display output like this 'Wed Aug 21 06:38:27 CDT 2013' ). But the java application is having timezone set to GMT. This is causing a 5 hrs difference in time java use and actual system time. How can I have jvm use the same time as the system.
6 years ago
What would happen when we executing this sample code. This code complete execution without any exception, but I dont know what this code will do. Can any explain


public static void main(String... args) {

List myList = new ArrayList();
myList.add( "Hello" );
myList.add( "Java" );
myList.add( "World" );

ObjectOutputStream objectOutputStream=null;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
FileOutputStream fileOutputStream =null;
try
{
objectOutputStream = new ObjectOutputStream(bout);
objectOutputStream.writeObject(myList);
objectOutputStream.flush();

fileOutputStream = new FileOutputStream( new File("myfile") );
fileOutputStream.write(bout.toByteArray());
fileOutputStream.flush();
System.out.println("end "+ sdf.format( new Date() ))

}catch (Exception e) {
e.printStackTrace();
}
}

7 years ago
Thanks, It can be done this way. But I am looking for a solution from the struts framework. Thanks James
7 years ago
Hi James,

Thanks for the response. I thought of implementing it as you suggested. But this will not resolve the problem

Here is code fragment that I am using.

From action class i am setting this two attributes
httpServletRequest.setAttribute("recordsIterator", records.values().iterator() ); // records is a HashMap instance
httpServletRequest.setAttribute("stationStatusMap", stationStatus); // stationStatus is another instance of HashMap


This is the JSP file. I am reading values from the iterator passed from the action class.
<logic:iterate name="recordsIterator" id="priceChangeRec" >
<tr>
<td><bean:write name="priceChangeRec" property="stationName"/></td>
<td><bean:write name="priceChangeRec" property="changeDirection"/></td>
<td>
<input type="text" size="5" value="<bean:write name="priceChangeRec" property="priceProduct1"/>" />
</td>
<td>
<input type="text" size="5" value="<bean:write name="priceChangeRec" property="priceProduct2"/>" />
</td>
<td>
<input type="text" size="5" value="<bean:write name="priceChangeRec" property="priceProduct3"/>" />
</td>
<td>
<input type="text" size="5" value="<bean:write name="priceChangeRec" property="priceProduct4"/>" />
</td>
<td>
<input type="text" size="5" value="<bean:write name="priceChangeRec" property="priceProduct5"/>" />
</td>
</tr>
</logic:iterate>

As you can see each row in the table displays price of some products of a particular station. The second hashmap contains a status value of each station which is mapped against station name.
I need use the station name from the first iterator and read the status value from second map using that value. I have to display that station status along with price detail in each row for each station.

Hope I made the issue clear to you..

Thanks
John
7 years ago
Hi all,

I have two collection objects, say for example two HashMap instance employeName with empId as key and Empoyee name as value and employeeSalary contains empId as key and Salary as Value. The data in these two maps are related and need to be displayed in table. I need to display data from these two collections in page using single logic:iterate tag. I will be fetching empoyee name from employeeName and related salary value from second map employeeSalary using the empId key from first one.


Does struts supports this kind of requirement or I have to look for something else. What are the other option to display If I can not do it with single <logic:iterate> tag.

Thanks in advance.
7 years ago