Divorce is a very difficult experience, including the impact it can have on one's economic status.

A billionaire like Donald Trump may be able to survive divorce (though a prenuptial agreement is a good idea), but middle-class people can see their financial position turned upside down. The end of a marriage can have a particularly brutal effect on retirement savings.

But educating oneself about the financial implications of divorce can save many thousands of dollars.

Knowing the laws in your state is very important. Most Eastern and Midwestern states follow an "equitable distribution" approach where courts are allowed to take into account how much income was brought into the household by each spouse during the marriage.

But states that were originally settled by the French or Spanish, such as Arizona, California, Louisiana and Texas, have a "community property" system. Under this system, most property acquired during the marriage aside from gifts or inheritances is owned jointly by both spouses and must be divided 50-50 upon divorce.

While you were married, you accumulated assets of various kinds such as your home and retirement accounts. Now those assets have to be divided.

This is the moment when Uncle Sam will try to get his hands on some of your wealth. In other words, tax consequences and other penalties must be a top priority when reaching a settlement.

For example, let's say Paul and Cynthia were married for 10 years. They agreed to save for retirement through the 401(k) plan at Cynthia's company, because her employer offered a very generous matching contribution, while his employer didn't.

That money is still in Cynthia's name.

Now that they are divorcing, what happens to it? Will there be penalties if it is withdrawn and divided up?

This is just the sort of issue that must be discussed when negotiating a qualified domestic relations order. A QDRO is a court decree that names someone other than you as a recipient of your retirement assets.

This other person, known as the alternate payee, must be a former spouse, a child or another dependent. Nowadays, the issue usually arises with respect to 401(k)s and individual retirement accounts, though QDROs can also assign benefits from old-fashioned pension plans as well.

Those who are going through a divorce should be sure to ask their company's 401(k) plan administrator if there is a model QDRO form for the plan. Doing so early in the process will save time and expense.

If the QDRO is prepared properly under the laws of a state, any money removed from the retirement account won't be subject to the early-withdrawal federal income tax penalty. The court decree can stipulate how the money is to be transferred: in one lump sum or in a series of payments over a specified period of time.

For those facing unavoidable financial expenses, as is the case with many individuals going through a divorce, this is a onetime opportunity to get some of that money now to pay current bills. But this must be spelled out clearly in the order on which the court signs off.

For those who roll the money into a new retirement account and then realize they need ready cash, it is too late; they will have to pay early withdrawal penalties.

Cashing Out

When divorcing, there may be a strong temptation start staking a claim to various assets: selling off stocks and bonds, cashing out certificates of deposit, clearing out bank accounts, etc. But don't let emotions blind you to the consequences of these actions.

TheStreet Recommends

Selling off stocks from non-retirement accounts could leave you facing substantial capital gains taxes at a time when you don't need more financial headaches.

And just because you transferred the money to a non-joint account in the waning days of the marriage doesn't really make a difference. Property acquired during the marriage will still have to be divided in the final divorce using either the "equitable distribution" or "community property" approach, depending on the state.

Alimony is still an issue in many divorces. But in the modern era, it is less often a lifelong award and more often used to give the lower-income spouse time to get back on his or her feet.

Factors that affect alimony awards include the length of the marriage, the spouse's age, whether the spouse has a job, how much the spouse earns, any other assets he or she has, the nature of the dissolution of the marriage, and the need.

Of course, the basic reality of divorce is that one household will now be two. That means two sets of bills: two mortgages or rent checks, two sets of utility bills, etc.

All this must be kept in mind when working out a new budget.

What about health insurance? It is fairly common for one spouse to be covered by the other's employer-based policy.

If you were covered through your spouse, and he or she works for a company that employs 20 or more people, then you are eligible to apply for continued health insurance coverage in that company's plan under a federal law known as "COBRA" (the Consolidated Omnibus Budget Reconciliation Act of 1986).

If the company has fewer than 20 employees, you might still be eligible for continued coverage under the mini-COBRA coverage laws of your state. State laws can differ quite significantly from those provided by the federal COBRA, so you will need to research the coverage terms and eligibility rules.

Finally, don't forget how expensive legal bills can be. If you and your spouse aren't truly at each other's throats, you might be able to get things settled using a mediator rather than the full adversarial legal process.

There are even people called certified divorce financial analysts who specialize in recommending optimal financial strategies for divorcing couples.

Mediation is substantially less costly than a full-scale court battle, both financially and psychologically.

Also consider consulting a financial adviser.

Individuals often begin their retirement planning with images of clear sailing in mind. But the key is to guard against the unexpected setbacks such as divorce, job loss and medical expenses.

Never lose sight of the ultimate goal of all your investment efforts: a safe and secure retirement.

Ultimate Retirement Guide: Are you making the right investment moves for your retirement, or are you blowing it by making all-too-common money mistakes?

There are crucial steps to build wealth over the long haul. To find out whether you will have enough money in your later years, download our free report: Your Ultimate Retirement Guide.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.