MyActivity
myurl private static final String url ="https://tripfareapi.herokuapp.com/flightapi/src=DEL&dest=BOM&depdate=";
使用Intent
Bundle bundle = getIntent().getExtras();
String from = bundle.getString("from");
String to = bundle.getString("to");
depaturedate = bundle.getString("departuredate");
我的网址,我希望附加原始网址,其中包含我从意图中选择的所选日期
newurl = url+depaturedate;
我的截击
private void getdata() {
StringRequest request = new StringRequest(newurl,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(request);
}
答案 0 :(得分:1)
您可以使用SimpleDateFormat
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String depDate= formatter.format(depaturedate);
url += depDate;
要使用SimpleDateFormat
,您必须import java.text.SimpleDateFormat;
String
:
departuredate = departuredate.replace("/", "");
url += departuredate;
答案 1 :(得分:1)
试试这个
depaturedate = depaturedate.replace("/", "");
newurl = url+depaturedate;