mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8308022: update for deprecated sprintf for java.base
Reviewed-by: naoto
This commit is contained in:
parent
1264902517
commit
42ca6e6942
6 changed files with 37 additions and 32 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -588,14 +588,14 @@ getGMTOffsetID()
|
|||
// Ignore daylight saving settings to calculate current time difference
|
||||
localtm.tm_isdst = 0;
|
||||
int gmt_off = (int)(difftime(mktime(&localtm), mktime(&gmt)) / 60.0);
|
||||
sprintf(buf, (const char *)"GMT%c%02.2d:%02.2d",
|
||||
snprintf(buf, sizeof(buf), (const char *)"GMT%c%02.2d:%02.2d",
|
||||
gmt_off < 0 ? '-' : '+' , abs(gmt_off / 60), gmt_off % 60);
|
||||
#else
|
||||
if (strftime(offset, 6, "%z", &localtm) != 5) {
|
||||
return strdup("GMT");
|
||||
}
|
||||
|
||||
sprintf(buf, (const char *)"GMT%c%c%c:%c%c", offset[0], offset[1], offset[2],
|
||||
snprintf(buf, sizeof(buf), (const char *)"GMT%c%c%c:%c%c", offset[0], offset[1], offset[2],
|
||||
offset[3], offset[4]);
|
||||
#endif
|
||||
return strdup(buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue