Accessing History
To view your conversion history:- From the main menu, select option 7
- The application displays all conversions made during the current session
- Press any key to return to the main menu
History viewing is implemented in
ConversorApp.java:32-41 and uses Java streams with lambda expressions for efficient displayHistory Format
Each conversion record follows this format:Format Components
Timestamp
Date and time when the conversion was performed, formatted as day-month-year with 24-hour time
Original Amount
The amount you entered for conversion
Base Currency
The currency you converted from (e.g., USD, ARS, BRL, COP)
Result
The converted amount in the target currency
Example History Output
With Conversions
When you have performed conversions, the history displays:Empty History
If no conversions have been performed yet, you’ll see:Empty history check is handled in
ConversorApp.java:34-36RegistroConversion Record Structure
History entries are stored using theRegistroConversion record class, which is a Java record type providing immutable data storage.
Record Fields
The
RegistroConversion record is defined in /workspace/source/src/lad/com/alura/conversormoneda/modelos/RegistroConversion.java:6Custom toString() Method
The record overrides thetoString() method to provide formatted output:
Custom
toString() implementation is in RegistroConversion.java:9-13How History is Created
After each successful conversion:-
A new
RegistroConversionobject is created with:- Base currency code
- Target currency code
- Original amount
- Conversion result
- Current timestamp (
LocalDateTime.now())
-
The record is added to the
historialArrayList - The list persists for the entire session
History creation happens in
ConversorApp.java:83-84 after each conversionHistory Persistence
The history is stored in memory using an
ArrayList<RegistroConversion> and persists only during the current application session. When you exit the application (option 8), the history is cleared.History list initialization is in
ConversorApp.java:18Using Lambda Expressions
The history display uses Java’s functional programming features:toString() method, providing clean and efficient code.
Lambda-based display is implemented in
ConversorApp.java:37