hotspot/src/share/vm/runtime/os.cpp
changeset 33604 ad1cd9269bd4
parent 33593 60764a78fa5c
child 33763 cec2333f839c
equal deleted inserted replaced
33603:450d454670a7 33604:ad1cd9269bd4
    94 // and strftime doesn't do milliseconds.
    94 // and strftime doesn't do milliseconds.
    95 char* os::iso8601_time(char* buffer, size_t buffer_length) {
    95 char* os::iso8601_time(char* buffer, size_t buffer_length) {
    96   // Output will be of the form "YYYY-MM-DDThh:mm:ss.mmm+zzzz\0"
    96   // Output will be of the form "YYYY-MM-DDThh:mm:ss.mmm+zzzz\0"
    97   //                                      1         2
    97   //                                      1         2
    98   //                             12345678901234567890123456789
    98   //                             12345678901234567890123456789
    99   static const char* iso8601_format =
    99   // format string: "%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d%02d"
   100     "%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d%02d";
       
   101   static const size_t needed_buffer = 29;
   100   static const size_t needed_buffer = 29;
   102 
   101 
   103   // Sanity check the arguments
   102   // Sanity check the arguments
   104   if (buffer == NULL) {
   103   if (buffer == NULL) {
   105     assert(false, "NULL buffer");
   104     assert(false, "NULL buffer");
   156     ((abs_local_to_UTC % seconds_per_hour) / seconds_per_minute);
   155     ((abs_local_to_UTC % seconds_per_hour) / seconds_per_minute);
   157 
   156 
   158   // Print an ISO 8601 date and time stamp into the buffer
   157   // Print an ISO 8601 date and time stamp into the buffer
   159   const int year = 1900 + time_struct.tm_year;
   158   const int year = 1900 + time_struct.tm_year;
   160   const int month = 1 + time_struct.tm_mon;
   159   const int month = 1 + time_struct.tm_mon;
   161   const int printed = jio_snprintf(buffer, buffer_length, iso8601_format,
   160   const int printed = jio_snprintf(buffer, buffer_length,
       
   161                                    "%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d%02d",
   162                                    year,
   162                                    year,
   163                                    month,
   163                                    month,
   164                                    time_struct.tm_mday,
   164                                    time_struct.tm_mday,
   165                                    time_struct.tm_hour,
   165                                    time_struct.tm_hour,
   166                                    time_struct.tm_min,
   166                                    time_struct.tm_min,