Magento 2 : How to get current category from registry

<?php

$registry = $objectManager->get('Magento\Framework\Registry');
$category = $objectManager->create('Magento\Catalog\Model\Category')->load($registry->registry('current_category')->getId());

?>

OR

<?php 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
    echo $category->getId();
    echo $category->getName();
?>