Charging issue

When my phone is charging the phone does not recognize that it is charging, and the battery level percentage will not go up. However if I give it some time to charge, then restart the phone...it will show that it has charged. It can charge up to 100% no problem in a normal amount of time. But like I said if I leave it on the whole time its plugged in it could show 2% when realistically its charged to 100%.