"When her husband Elkanah went up with all his family to offer the annual sacrifice to the Lord and to fulfill his vow, Hannah did not go. She said to her husband, 'After the boy is weaned, I will take and present him before the Lord, and he will live there always.'" NIV translation
Hannah and Samuel did not go up to Shiloh until he was weaned which could have been up to three years.
"'Do what seems best to you, ' her husband Elkanah told her.' Stay here until you have weened him; only may the Lord make good his word.' So the woman stayed home and nursed her son until she had weaned him." NIV translation
Elkanah must have really trusted Hannah to listen to the Lord. He did not argue with her but instead only asked for the Lord to keep His word.
"After he was weaned, she took the boy with her, young as he was, along with a three-year old bull, an ephah of flour and a skin of wine, and brought him to the house of the Lord at Shiloh. When the bull had been sacrificed, they brought the boy to Eli, and she said to him, 'Pardon me, my lord, As surely as you live, I am the woman who stood here beside you praying to the Lord. I prayed for this child, and the Lord has granted me what I asked of him. So now I give him to the Lord. For his whole life he will be given over to the Lord.' And he worshiped the Lord there." NIV translation
We see that Hannah kept her oath to God and are reminded that God takes oaths very seriously. We are not required to take an oath but, if we do so, God expects us to keep it. Many times, people will promise God something during the tough times and forget about it when the storm passes. Here, we see the example of a Godly woman that was obedient and, by doing so, God would be glorified.