title: How to split "yyyy:MM:dd:HH:mm" format into separate date and time?
body: <p>I am developing an app,I am using Date and time picker, To pick an date and time and I set result time 6 hours before picked time. but the result time and date shows in <code>yyyy:MM:dd:HH:mm</code> this format and I want to show this date and time separately in textfields (like date is <code>yyyy:MM:dd</code> and time is <code>HH:mm</code>).How do I show this?</p>
  
  <pre><code>//java
  public class DateTime extends AppCompatActivity implements View.OnClickListener {
  
      Button btnDatePicker, btnTimePicker;
      EditText txtDate, txtTime;
      TextView dt, dt2;
      private int mYear, mMonth, mDay, mHour, mMinute;
      String selected_date="",selected_time="",new_date_time="";
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.datetime);
  
          btnDatePicker=(Button)findViewById(R.id.btn_date);
          btnTimePicker=(Button)findViewById(R.id.btn_time);
          txtDate=(EditText)findViewById(R.id.in_date);
          txtTime=(EditText)findViewById(R.id.in_time);
          dt=(TextView)findViewById(R.id.textView_dt);
          dt2=(TextView)findViewById(R.id.textView_dt1);
  
          btnDatePicker.setOnClickListener(this);
          btnTimePicker.setOnClickListener(this);
  
      }
  
      @Override
      public void onClick(View v) {
  
          if (v == btnDatePicker) {
  
              // Get Current Date
              final Calendar c = Calendar.getInstance();
              mYear = c.get(Calendar.YEAR);
              mMonth = c.get(Calendar.MONTH);
              mDay = c.get(Calendar.DAY_OF_MONTH);
  
  
              DatePickerDialog datePickerDialog = new DatePickerDialog(this,
                      new DatePickerDialog.OnDateSetListener() {
  
                          @Override
                          public void onDateSet(DatePicker view, int year,
                                                int monthOfYear, int dayOfMonth) {
  
                              txtDate.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
                              selected_date=year+":"+(monthOfYear + 1)+":"+dayOfMonth;
                          }
                      }, mYear, mMonth, mDay);
  
              datePickerDialog.show();
          }
          if (v == btnTimePicker) {
  
              // Get Current Time
              final Calendar c = Calendar.getInstance();
              mHour = c.get(Calendar.HOUR_OF_DAY);
              mMinute = c.get(Calendar.MINUTE);
  
              // Launch Time Picker Dialog
              TimePickerDialog timePickerDialog = new TimePickerDialog(this,
                      new TimePickerDialog.OnTimeSetListener() {
  
                          @Override
                          public void onTimeSet(TimePicker view, int hourOfDay,
                                                int minute) {
  
                              txtTime.setText(hourOfDay + ":" + minute);
                              selected_time=hourOfDay+":"+minute;
                              setBeforeSixTime();
                          }
                      }, mHour, mMinute, false);
  
              timePickerDialog.show();
  
          }
  
      }
  
      private void setBeforeSixTime() {
          try {
              Log.d("Time here ", "hiii");
              SimpleDateFormat simpleDateFormat = new SimpleDateFormat(selected_date + ":" + selected_time);
              String my_date = simpleDateFormat.format(new Date());
              DateFormat formatter = new SimpleDateFormat("yyyy:MM:dd:HH:mm");
           //   DateFormat formatter = new SimpleDateFormat("dd:MM:yyyy:HH:mm");
              Date date = (Date) formatter.parse(my_date);
              Calendar calendar = Calendar.getInstance();
              calendar.setTime(date);
              calendar.add(Calendar.HOUR, -6);
  
              Log.d("Time here ", formatter.format(calendar.getTime()));
              String s=formatter.format(calendar.getTime());
              dt.setText(s);
          } catch (Exception e) {
              Log.d("Exception", "" + e);
          }
      }
  }
  </code></pre>