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:
7:27a1cf7f8921
Parent:
6:5ada291037aa
Child:
8:bf593344668e
--- a/main.cpp	Fri Jan 29 07:51:04 2016 +0000
+++ b/main.cpp	Fri May 27 20:19:49 2016 +0000
@@ -2,11 +2,11 @@
  * mbed Application program
  *      RTC (inside STM32x CPU) test program
  *
- * Copyright (c) 2015 Kenji Arai / JH1PJL
+ * Copyright (c) 2015,'16 Kenji Arai / JH1PJL
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created: January   17th, 2015
- *      Revised: May       24th, 2015
+ *      Revised: May       28th, 2016
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -26,20 +26,21 @@
 
 //#define USE_LCD
 
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) \
- || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F334R8)
+#if (defined(TARGET_STM32F401RE) || defined(TARGET_STM32F411RE) \
+  || defined(TARGET_STM32L152RE) || defined(TARGET_STM32F334R8) \
+  || defined(TARGET_STM32L476RG) )
 #else
-#error "Target is only Nucleo F401RE, F411RE, F334R8 and L152RE"
+#error "Target is only Nucleo F401RE, F411RE, F334R8, L476RG and L152RE"
 #endif
 
 //  Object ----------------------------------------------------------------------------------------
 DigitalIn userSW(USER_BUTTON);
 DigitalOut myled(LED1);         // Indicate the sampling period
 Serial pc(USBTX, USBRX);
-//#if defined(USE_LCD)
+#if defined(USE_LCD)
 I2C i2c(D14,D15);               // SDA, SCL
 TextLCD_I2C_N lcd(&i2c, 0x7c, TextLCD::LCD8x2);  // LCD(Akizuki AQM0802A)
-//#endif
+#endif
 DigitalOut pwr_onoff(PA_9);
 
 //  RAM -------------------------------------------------------------------------------------------
@@ -105,8 +106,8 @@
 #endif
         --counter;
         if (counter){
-            //      012345678901234567890123456789012345678901234567890123456789012
-            pc.printf("Is time correct? If no, hit any key.\r");
+            //         012345678901234567890123456789012345678901234567890123456789012
+            pc.printf("Is a time correct? If no, please hit any key for adjustment.\r");
         }
         wait_counter = 0;
         while (seconds == time(NULL)){
@@ -141,7 +142,7 @@
         }
         if (counter){
             //         12345678901234567890123456789012345678901234567890
-            pc.printf("                                                  \r");
+            pc.printf("                                                  \r"); // Not use '\n'
         }
         myled = !myled;
     }