In the past, you need modify rtc_api.c in mbed-dev source code. From this revision, you can just use RTC function all of conditions (Normal, Reset, Stand-by, Power OFF).

Note

From now on, you do NOT need any modification for mbed-dev library because STM team updates rtc_api.c source code and support RTC function under reset & standby condition includes power off condition (You need additional VBAT back-up hardware).

Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/

Revision:
12:8cb1f89541d1
Parent:
11:2e514d955a2b
Child:
13:c1f984932e98
--- a/main.cpp	Sat Aug 01 07:26:13 2020 +0000
+++ b/main.cpp	Wed Jan 06 23:57:37 2021 +0000
@@ -2,11 +2,11 @@
  * mbed Application program
  *      RTC (inside STM32x CPU) test program
  *
- * Copyright (c) 2015,'16,'17,'20 Kenji Arai / JH1PJL
+ * Copyright (c) 2015,'16,'17,'20, '21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created: January   17th, 2015
- *      Revised: August     1st, 2020
+ *      Revised: January    6th, 2021
  */
 
 /*  mbed library now suports RTC continuous operation at Reset & Power ON/OFF
@@ -24,12 +24,12 @@
     Nucleo-F401RE /  ok    /  ok     / ok (need following Back-up Circuit)
     Nucleo-F411RE /  ok    /  ok     / ok (need following Back-up Circuit)
     Nucleo-F446RE /  ok    /  ok     / ok (need following Back-up Circuit)
-    not support on Mbed-os6.2.0 Nucleo-F334R8
+    not support on Mbed-os6.6.0 Nucleo-F334R8
     Nucleo-L476RG /  ok    /  ok     / ok (need following Back-up Circuit)
     DISCO-L45VG-IOT/ ok    /  ok     / ok (Need additional hardware)
     Nucleo-L152RE /  ok    /  ok     / no check (Need additional hardware)
     Nucleo-L073RZ /  ok    /  ok     / no check (Need additional hardware)
-    not support on Mbed-os6.2.0 Nucleo-L053R8
+    not support on Mbed-os6.6.0 Nucleo-L053R8
 
     < Back-up circuit >
     CN7 VIN <- SBD <- 330 Ohm <- CR2032 + - -> CN7 GND
@@ -160,7 +160,7 @@
     char linebuf[64];
 
     puts("Set time into RTC.");
-    puts(" e.g. >20 8 1 12 34 56 -> August 01,'20, 12:34:56");
+    puts(" e.g. >21 1 6 12 34 56 -> January 06,'21, 12:34:56");
     puts(" If time is fine, just hit enter key.");
     linebuf[0] = '>';
     pc.write(linebuf, 1);