ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Milliseconds or NanoSeconds truncation in MbTimestamp

Post new topic  Reply to topic
 Milliseconds or NanoSeconds truncation in MbTimestamp « View previous topic :: View next topic » 
Author Message
er_pankajgupta84
PostPosted: Sat Apr 04, 2009 11:31 am    Post subject: Milliseconds or NanoSeconds truncation in MbTimestamp Reply with quote

Master

Joined: 14 Nov 2008
Posts: 203
Location: charlotte,NC, USA

I am using MbSQLStatement to fetch a TIMESTAMP field from DB in a java compute node. The problem is that the TIMESTAMP field in Db uses 6 digits for storing milliseconds... but MbTimestamp only give upto 3 digits of milliseconds..

For example:
If Value in DB is 28-02-2009 12:15:34:123456
then MbTimestamp will only store 28-02-2009 12:15:34:123

Any idea how can i get the complete 6 digits of milliseconds....

I can't use java / ResultSet to query database... due to restrictions.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
fjb_saper
PostPosted: Sat Apr 04, 2009 5:04 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Note that the MBTimestamp class is an extension of the GregorianCalendar (see java.util) package. As such you can do / display all you can do with a gregorian calendar. Have you tried using a simple date format with it? What was the result? Why do you need precision to the nanosecond? Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Sat Apr 04, 2009 10:35 pm    Post subject: Re: Milliseconds or NanoSeconds truncation in MbTimestamp Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Just to clear up the terminology:
  • millisecond = 10^-3 second (3 digits)
  • microsecond = 10^-6 second (6 digits)
  • nanosecond = 10^-9 second (9 digits)
MbTimestamp extends GregorianCalendar, which extends Calendar, which only supports at most millisecond granularity.

With a Java Compute node, one option is to use the MbSQLStatement to store Database timestamp somewhere in the message assembly, retrieve value with MbElement.getValueAsString(), and parse the string to get microseconds. (edit: this method is not available for version WMB 6.0 or earlier)

Other options include using an ESQL Compute node, or a C custom node, instead of a Java Compute node.

Yet another option is to revisit the requirements; is microsecond resolution necessary?


Last edited by rekarm01 on Sun Apr 05, 2009 1:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
er_pankajgupta84
PostPosted: Sun Apr 05, 2009 11:06 am    Post subject: Reply with quote

Master

Joined: 14 Nov 2008
Posts: 203
Location: charlotte,NC, USA

Thanks for your replies.....

Thanks for clarifying the terminology...

I need MICROSECONDS... but MbTimestamp doesn't give it...

Here is the string representation of MbTimestamp value retrieved from the message Assembly returned (populated) from the database query.

com.ibm.broker.plugin.MbTimestamp[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,
zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,
lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,
startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,
endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,
ERA=?,
YEAR=2009,
MONTH=3,
WEEK_OF_YEAR=?,
WEEK_OF_MONTH=?,
DAY_OF_MONTH=3,
DAY_OF_YEAR=?,
DAY_OF_WEEK=?,
DAY_OF_WEEK_IN_MONTH=?,
AM_PM=1,
HOUR=3,
HOUR_OF_DAY=15,
MINUTE=11,
SECOND=26,
MILLISECOND=553,
ZONE_OFFSET=?,
DST_OFFSET=?]

There is no function like getValueAsString defined for MbElement....and if you mean to get value of MbElement and then convert it in string...then the value for MICROSECOND is not present...

Can some one provide more details on parent class of MbTimeStamp...
[edit]reformatted for better reading experience by moderator[/edit]
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
er_pankajgupta84
PostPosted: Sun Apr 05, 2009 11:16 am    Post subject: Reply with quote

Master

Joined: 14 Nov 2008
Posts: 203
Location: charlotte,NC, USA

I have also checked the GregarianCalender class... it also produces the same result as that of MbTimestamp...

Any idea...how can we get MICROSECONDS from a database using MbSQL in JCN.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
rekarm01
PostPosted: Sun Apr 05, 2009 1:15 pm    Post subject: Re: Milliseconds or NanoSeconds truncation in MbTimestamp Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

er_pankajgupta84 wrote:
I need MICROSECONDS... but MbTimestamp doesn't give it...

Can some one provide more details on parent class of MbTimeStamp...

No, MbTimestamp doesn't give microseconds. See http://java.sun.com/j2se/1.4.2/docs/api/ for more details about the WMB 6.0 Java API.

er_pankajgupta84 wrote:
Here is the string representation of MbTimestamp value retrieved from the message Assembly returned (populated) from the database query.

Please re-edit your post to wrap extra-long lines. For some browsers, extra-long lines mess up the formatting of the entire thread.

er_pankajgupta84 wrote:
There is no function like getValueAsString defined for MbElement.

Sorry, that's defined for WMB 6.1, but not for earlier versions.

er_pankajgupta84 wrote:
Any idea...how can we get MICROSECONDS from a database using MbSQL in JCN.

One suggestion is to try using an MbSQLstatement to CAST the TIMESTAMP AS CHARACTER, and use MbElement.getValue() to get the resulting string.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Apr 05, 2009 2:34 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

fjb_saper wrote:
Have you tried using a SimpleDateFormat with it? What was the result? Why do you need precision to the micro/nanosecond? Have fun

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Milliseconds or NanoSeconds truncation in MbTimestamp
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.