SimpleDateFormat parse() Method in Java with Examples Last Updated : 12 Oct, 2021 Comments Improve Suggest changes Like Article Like Report The parse() Method of SimpleDateFormat class is used to parse the text from a string to produce the Date. The method parses the text starting at the index given by a start position.Syntax: public Date parse(String the_text, ParsePosition position) Parameters: The method takes two parameters: the_text: This is of the String type and refers to the string which is to be parsed to produce the date.position: This is of ParsePosition object type and refers to the information of the starting index of the parse. Return Value: The method either returns the Date parsed from the string or Null in case of an error.Below programs illustrate the working of parse() Method of SimpleDateFormat: Example 1: Java // Java Code to illustrate parse() method import java.text.*; import java.util.Calendar; public class SimpleDateFormat_Demo { public static void main(String[] args) throws InterruptedException { SimpleDateFormat SDFormat = new SimpleDateFormat("MM/ dd/ yy"); try { Calendar cal = Calendar.getInstance(); // Use of .parse() method to parse // Date From String String dt = "10/ 27/ 16"; System.out.println("The unparsed" + " string is: " + dt); cal.setTime(SDFormat.parse(dt)); System.out.println("Time parsed: " + cal.getTime()); } catch (ParseException except) { except.printStackTrace(); } } } Output: The unparsed string is: 10/ 27/ 16 Time parsed: Thu Oct 27 00:00:00 UTC 2016 Example 2: Java // Java Code to illustrate parse() method import java.text.*; import java.util.Calendar; public class SimpleDateFormat_Demo { public static void main(String[] args) throws InterruptedException { SimpleDateFormat SDFormat = new SimpleDateFormat("MM/ dd/ yy"); try { Calendar cal = Calendar.getInstance(); // Use of .parse() method to parse // Date From String String dt = "01/ 29/ 19"; System.out.println("The unparsed" + " string is: " + dt); cal.setTime(SDFormat.parse(dt)); System.out.println("Time parsed: " + cal.getTime()); } catch (ParseException except) { except.printStackTrace(); } } } Output: The unparsed string is: 01/ 29/ 19 Time parsed: Tue Jan 29 00:00:00 UTC 2019 Comment More infoAdvertise with us Next Article SimpleDateFormat parse() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java-Functions Java-text package Java-SimpleDateFormat +1 More Practice Tags : JavaMisc Similar Reads SimpleDateFormat format() Method in Java with Examples The format() Method of SimpleDateFormat class is used to format a given date into Date/Time string. Basically the method is used to convert this date and time into a particular format for say mm/dd/yyyy.Syntax: public final String format(Date date) Parameters: The method takes one parameter date of 2 min read Period parse() method in Java with Examples The parse() method of Period Class is used to obtain a period from given string in the form of PnYnMnD where nY means n years, nM means n months and nD means n days. Syntax: public static Period parse(CharSequence text) Parameters: This method accepts a single parameter text which is the String to b 2 min read SimpleDateFormat applyPattern() Method in Java with Examples The applyPattern() Method of SimpleDateFormat class is used to set a given defined pattern to the Date Format. It simply converts a particular date and time to a specific format as defined by the user for eg., dd/ MM/ yyyy HH:mm Z or MM/ dd/ yyyy HH:mm Z.Syntax: public void applyPattern(String patte 2 min read Float parseFloat() method in Java with examples The parseFloat() method in Float Class is a built in method in Java that returns a new float initialized to the value represented by the specified String, as done by the valueOf method of class Float. Syntax: public static float parseFloat(String s) Parameters: It accepts a single mandatory paramete 2 min read ZonedDateTime parse() method in Java with Examples In ZonedDateTime class, there are two types of parse() method depending upon the parameters passed to it. parse(CharSequence text) parse() method of a ZonedDateTime class used to get an instance of ZonedDateTime from a string such as '2018-12-06T19:21:12.123+05:30[Asia/Calcutta]' passed as parameter 2 min read Like