TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Automation

    Convert String to Date in Java

    Overview

    In this tutorial, we will convert String to Date in Java sample program.

    Sample Java Program

    import java.util.*;
    import java.text.*;
    
    /**************************************
     * 
     * Sample String to Date Java Program
     * Java Tutorials
     * www.TestingDocs.com
     * 
     **************************************/
    public class StringToDateDemo {
     public static void main(String[] args) {
     try { 
     String dateStr ="21-Dec-2012";
     Date date; 
     DateFormat formatter; 
     formatter = new SimpleDateFormat("dd-MMM-yyyy");
     date = (Date)formatter.parse(dateStr); 
     Calendar calendar=Calendar.getInstance();
     calendar.setTime(date);
     System.out.println("Date is :=" + date );
     } catch (Exception exp)
     {
     System.out.println("Exception :"+exp);
     } 
     }
    } 

    Screenshot

    String to Date Java Program

    Related Posts

    Automation /

    Dart return Statement

    Emma Tool

    Automation /

    Code Coverage Tools

    Selenium 4 Automation Project

    Automation /

    Selenium 4 Project Setup on Ubuntu Linux

    Testing webpage mobile-friendliness using a tool

    Automation /

    Testing webpage mobile-friendliness using a tool

    Errors Code Testing Development

    Automation /

    Error Severity Metrics

    ‹ UML Class Diagram› Types of Software Test Plans

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com