Java Parse Date Pattern YYYY parseSessionTime(String response)

Here you can find the source of parseSessionTime(String response)

Description

parse Session Time

License

Apache License

Declaration

private static List<Date> parseSessionTime(String response) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Main {
    private static List<Date> parseSessionTime(String response) {
        List<Date> res = new ArrayList<Date>();

        int idx = response.indexOf("<div class=\"purple_box\">");
        while (idx > 0) {
            int sDayIdx = response.indexOf(">", idx + 10) + 1;
            String day = response.substring(sDayIdx,
                    response.indexOf("<", sDayIdx));

            SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
            Date utilDate = null;
            try {
                utilDate = format.parse(day);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();//  w  w  w.  j av  a2 s.  c  o  m
            }
            idx = response.indexOf("/visLtyTicketsLogin.aspx", idx + 10);

            int endDayIdx = response.indexOf("</ul>", idx);
            while (idx > 0 && idx < endDayIdx) {
                int sTime = response.indexOf(">", idx) + 1;
                int eTime = response.indexOf("<", sTime);
                String time = response.substring(sTime, eTime).trim();
                int hour = Integer.parseInt(time.substring(0, 2));
                int mins = Integer.parseInt(time.substring(3, 5));

                long addTime = 60 * 60 * 1000 * hour + 60 * 1000 * mins;
                Date sesTime = utilDate != null ? new Date(
                        utilDate.getTime() + addTime) : null;
                res.add(sesTime);
                idx = response.indexOf("/visLtyTicketsLogin.aspx",
                        eTime + 10);

            }

            idx = response.indexOf("<div class=\"purple_box\">", endDayIdx);
        }

        return res;
    }
}

Related

  1. parseRoundTripDateString(String roundTripString)
  2. parseRSSDate(String dateStr)
  3. parseSalesDate(final String ymd)
  4. parseSecureDate(final String dateString)
  5. parseSegKeyDate4Display(String source)
  6. parseSilently(String p_string)
  7. parseSimpleDate(String string, Date defaultDate)
  8. parseSipDateTime(String dateStr)
  9. parseSolrDate(String date)