Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 30229 Details for
Bug 112371
Performance and memory improvements for the three producer Common Base Event implementations.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
EventHelpersPerformancePatch.txt
EventHelpersPerformancePatch.txt (text/plain), 6.92 KB, created by
Paul Slauenwhite
on 2005-11-18 10:47:07 EST
(
hide
)
Description:
EventHelpersPerformancePatch.txt
Filename:
MIME Type:
Creator:
Paul Slauenwhite
Created:
2005-11-18 10:47:07 EST
Size:
6.92 KB
patch
obsolete
>Index: EventHelpers.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.hyades.logging.core/src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventHelpers.java,v >retrieving revision 1.12 >diff -u -r1.12 EventHelpers.java >--- EventHelpers.java 3 Jun 2005 02:35:14 -0000 1.12 >+++ EventHelpers.java 17 Nov 2005 17:12:54 -0000 >@@ -83,12 +83,15 @@ > > //NOTE: Set the locale of the date format to English since the > //XSD:dateTime format is used which is locale agnostic. >- private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss",Locale.ENGLISH); >+ private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH); >+ >+ //TODO: May need to update if default locale changes. >+ private static Calendar calendar = new GregorianCalendar(new SimpleTimeZone(0, "UTC")); > > static { > >- Calendar calendar = new GregorianCalendar(new SimpleTimeZone(0, "UTC")); >- calendar.setLenient(false); >+ //Calendar calendar = new GregorianCalendar(new SimpleTimeZone(0, "UTC")); >+ //TODO: calendar.setLenient(false); > > simpleDateFormat.setLenient(false); > simpleDateFormat.setCalendar(calendar); >@@ -428,16 +431,17 @@ > > return milliseconds; > } >- >- >+ public static void main(String[] args) { >+ System.out.println(longToDate(System.currentTimeMillis())); >+ } > /** > * Converts a long representing UTC in milliseconds to the XML Schema >- * datetime format (CCYY-MM-DDThh:mm:ssZ) >+ * XSD:dateTime format (YYYY-MM-dd'T'HH:mm:ss.SSS'Z') > * <p> > * > * @param dateInMillis > * A long representing a coordinated universal time (UTC) time stamp in milliseconds. >- * @return The date in string format (CCYY-MM-DDThh:mm:ssZ) >+ * @return The date in string format (YYYY-MM-dd'T'HH:mm:ss.SSS'Z') > * @throws IllegalArgumentException > * If the long representing a coordinated universal time (UTC) time stamp in milliseconds is negative. > * @see org.eclipse.hyades.logging.events.cbe.CommonBaseEvent#setCreationTimeAsLong(long) >@@ -448,85 +452,81 @@ > throw new IllegalArgumentException(dateInMillis + " cannot be negative."); > } > >- String dateTime = null; >- >- // create a the GMT timezone >- SimpleTimeZone gmt = new SimpleTimeZone(0, "UTC"); >- >- // create a GregorianCalendar with the GMT time zone >- Calendar calendar = new GregorianCalendar(gmt); >- >- // set the date in the calendar >- calendar.setTime(new Date(dateInMillis)); >- >- // get the interger representation for all the fields >- int year = calendar.get(Calendar.YEAR); >- int month = calendar.get(Calendar.MONTH); >- >- // java has January as month 0 so need add 1 to the month >- month++; >- >- int day = calendar.get(Calendar.DAY_OF_MONTH); >- int hour = calendar.get(Calendar.HOUR_OF_DAY); >- int minute = calendar.get(Calendar.MINUTE); >- int second = calendar.get(Calendar.SECOND); >- int milliseconds = calendar.get(Calendar.MILLISECOND); >- >- // now create a string buffer to build the string >- // if the fields are not the correct size they must be padded with 0's >- StringBuffer stringBuffer = new StringBuffer(35); >- stringBuffer.append(year); >- stringBuffer.append('-'); >- >- if (month < 10) { >- stringBuffer.append("0"); >- } >- >- stringBuffer.append(month); >- stringBuffer.append('-'); >- >- if (day < 10) { >- stringBuffer.append("0"); >- } >- >- stringBuffer.append(day); >- stringBuffer.append('T'); >- >- if (hour < 10) { >- stringBuffer.append("0"); >- } >- >- stringBuffer.append(hour); >- stringBuffer.append(':'); >- >- if (minute < 10) { >- stringBuffer.append("0"); >- } >- >- stringBuffer.append(minute); >- stringBuffer.append(':'); >- >- if (second < 10) { >- stringBuffer.append("0"); >- } >- >- stringBuffer.append(second); >- >- stringBuffer.append("."); >+ synchronized (LOCK) { > >- if (milliseconds < 10) { >- stringBuffer.append("00"); >- } else if (milliseconds < 100) { >- stringBuffer.append("0"); >+ //Set the millisecond date on the calendar: >+ calendar.setTimeInMillis(dateInMillis); >+ >+ //Create the string buffer and build the XSD:dateTime string: >+ //NOTE: All fields less than two numbers in size must be zero padded. >+ //ASSUMPTION: The XSD:dateTime string is at most 24 characters in length (YYYY-MM-dd'T'HH:mm:ss.SSS'Z'). >+ StringBuffer stringBuffer = new StringBuffer(24); >+ stringBuffer.append(calendar.get(Calendar.YEAR)); >+ stringBuffer.append('-'); >+ >+ //NOTE: Numeric months in Java start from 0. >+ int month = (calendar.get(Calendar.MONTH) + 1); >+ >+ if (month < 10) { >+ stringBuffer.append('0'); >+ } >+ >+ stringBuffer.append(month); >+ stringBuffer.append('-'); >+ >+ int day = calendar.get(Calendar.DAY_OF_MONTH); >+ >+ if (day < 10) { >+ stringBuffer.append('0'); >+ } >+ >+ stringBuffer.append(day); >+ stringBuffer.append('T'); >+ >+ int hour = calendar.get(Calendar.HOUR_OF_DAY); >+ >+ if (hour < 10) { >+ stringBuffer.append('0'); >+ } >+ >+ stringBuffer.append(hour); >+ stringBuffer.append(':'); >+ >+ int minute = calendar.get(Calendar.MINUTE); >+ >+ if (minute < 10) { >+ stringBuffer.append('0'); >+ } >+ >+ stringBuffer.append(minute); >+ stringBuffer.append(':'); >+ >+ int second = calendar.get(Calendar.SECOND); >+ >+ if (second < 10) { >+ stringBuffer.append('0'); >+ } >+ >+ stringBuffer.append(String.valueOf(second)); >+ >+ stringBuffer.append('.'); >+ >+ int milliseconds = calendar.get(Calendar.MILLISECOND); >+ >+ if (milliseconds < 10) { >+ stringBuffer.append("00"); >+ } >+ else if (milliseconds < 100) { >+ stringBuffer.append('0'); >+ } >+ >+ stringBuffer.append(milliseconds); >+ >+ //NOTE: All XSD:dateTimes are in the UTC or Zulu (e.g. Z) time zone. >+ stringBuffer.append('Z'); >+ >+ return (stringBuffer.toString()); > } >- >- stringBuffer.append(milliseconds); >- >- // are times are always UTC so append a Z >- stringBuffer.append("Z"); >- dateTime = stringBuffer.toString(); >- >- return dateTime; > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 112371
:
28271
|
30229
|
30238