ho tempo in seguito formatoCrea 30 min slot da certa data e l'ora
2015-10-28T18: 37: 04.899 + 05: 30
devo creare slot in formato qui sotto
11:00-12:00 28/10/15
12:00-13:00 28/10/15
13:00-14:00 28/10/15
String timeValue = "2015-10-28T18:37:04.899+05:30";
StringTokenizer stringTokenizer = new StringTokenizer(timeValue,"T");
String dateValue = stringTokenizer.nextElement().toString();
String endDateValue = "2015-10-30";
String restString= stringTokenizer.nextElement().toString();
StringTokenizer secondTokeniser = new StringTokenizer(restString,":");
String hours = secondTokeniser.nextElement().toString();
String minutes = secondTokeniser.nextElement().toString();
hours = String.valueOf(Integer.parseInt(hours) + 2);
if (Integer.parseInt(minutes) > 30){
minutes = "00";
}else{
minutes = "30";
}
String amOrPm = null;
if(Integer.parseInt(hours) < 12){
amOrPm = "AM";
}else{
amOrPm = "PM";
hours = String.valueOf(getHoursValue(Integer.parseInt(hours)));
}
String time1 = hours + ":" + minutes + " " + amOrPm;
String time2 = "12" + ":" + "00" + " AM ";
String format = "yyyy-mm-dd hh:mm a";
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
Date dateObj1 = sdf.parse(dateValue + " " + time1);
Date dateObj2 = sdf.parse(endDateValue + " " + time2);
Logger.d(TAG, "Date Start: " + dateObj1);
Logger.d(TAG, "Date End: " + dateObj2);
long dif = dateObj1.getTime();
while (dif < dateObj2.getTime()) {
Date slot = new Date(dif);
Log.d(TAG, "Hour slot = " + slot);
dif += 1800000;
}
}catch (ParseException ex){
ex.printStackTrace();
}
Con il codice di cui sopra io sono sempre al di sotto di uscita
mer 28 gen 20:00:00 IST 2015
mer 28 gennaio 20:30:00 IST 2015
mer 28 gennaio 21:00:00 IST 2015
mer 28 gennaio 21:30:00 IST 2015
mer 28 gennaio 22:00:00 IST 2015
Mer 28 Gen 22: 30:00 IST 2015
che è in formato 24 ore
voglio il modello che segue mettere fuori
11:00-12:00 28/10/15
12:00-13:00 28/10/15
13:00-14:00 28/10/15
Can per favore qualcuno mi aiuti per quanto riguarda questo
Io davvero non capisco il punto di downvote, è diventato una tendenza qui – Naga
persone forse solo cattive che downvote senza lasciare un motivo –
sì credo di cui godono bro – Naga