title: How to parse String to Date in Android?
body: <p>I'm new to Android and I am having problem while parsing String to Date format. I am trying to retrieve data from Firebase and convert it to Date type.</p>
  
  <p>I have used SimpleDateFormat to parse and its working fine normally. The problem arise only when I try to parse data from Firebase. </p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fragment_activity, container, false);
         calT = Calendar.getInstance();
         calD = Calendar.getInstance();
         try {
             today = new SimpleDateFormat("dd-MMM-yy", Locale.getDefault()).parse(stoday); // WORKING FINE
         } catch (ParseException e) {
             e.printStackTrace();
         } 
  public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  
                         for (DataSnapshot activitySnapshot : dataSnapshot.getChildren()) {
                             ActivityData activityData = activitySnapshot.getValue(ActivityData.class);
                             DateOfEvent = String.valueOf(activitySnapshot.child("dateOfEvent").getValue());
                             try {
                                 date1 = new SimpleDateFormat("dd/MMM/yy",Locale.getDefault()).parse(DateOfEvent); //RETURNS NULL
                             } catch (ParseException e) {
                                 e.printStackTrace();
                             }
  </code></pre>
  
  <p>I expect the code to return Date, but it returns NULL. Thanks.</p>