Example usage for org.joda.time DateTime minusDays

List of usage examples for org.joda.time DateTime minusDays

Introduction

In this page you can find the example usage for org.joda.time DateTime minusDays.

Prototype

public DateTime minusDays(int days) 

Source Link

Document

Returns a copy of this datetime minus the specified number of days.

Usage

From source file:graph.inference.module.LaterThanWorker.java

License:Open Source License

private Interval parseDate(DAGNode date, DateTime now) {
    String dateStr = date.toString();
    if (dateStr.equals("Now") || dateStr.equals("Now-Generally"))
        return new Interval(now.getMillis(), now.getMillis() + 1);
    if (dateStr.equals("Today-Indexical"))
        return new Interval(now.dayOfYear().roundFloorCopy(), now.dayOfYear().roundCeilingCopy());
    if (dateStr.equals("Tomorrow-Indexical")) {
        return new Interval(now.plusDays(1).dayOfYear().roundFloorCopy(),
                now.plusDays(1).dayOfYear().roundCeilingCopy());
    }//from ww w.jav  a  2 s.co  m
    if (dateStr.equals("Yesterday-Indexical")) {
        return new Interval(now.minusDays(1).dayOfYear().roundFloorCopy(),
                now.minusDays(1).dayOfYear().roundCeilingCopy());
    }
    if (dateStr.equals("TheYear-Indexical")) {
        return new Interval(now.year().roundFloorCopy(), now.year().roundCeilingCopy());
    }

    // Parse the date from the DAGNode
    String parsePattern = null;
    for (int i = DATE_PARSE_INTERVALS.length - 1; i >= 0; i--) {
        StringBuilder newPattern = new StringBuilder("(" + DATE_PARSE_INTERVALS[i]);
        if (parsePattern != null)
            newPattern.append(" " + parsePattern);
        newPattern.append(")");
        parsePattern = newPattern.toString();

        DateTimeFormatter dtf = DateTimeFormat.forPattern(parsePattern);
        try {
            DateTime dateTime = dtf.parseDateTime(dateStr);
            if (dateTime != null) {
                switch (i) {
                case 0:
                    return new Interval(dateTime.getMillis(),
                            dateTime.plusSeconds(1).minusMillis(1).getMillis());
                case 1:
                    return new Interval(dateTime.getMillis(),
                            dateTime.plusMinutes(1).minusMillis(1).getMillis());
                case 2:
                    return new Interval(dateTime.getMillis(), dateTime.plusHours(1).minusMillis(1).getMillis());
                case 3:
                    return new Interval(dateTime.getMillis(), dateTime.plusDays(1).minusMillis(1).getMillis());
                case 4:
                    return new Interval(dateTime.getMillis(),
                            dateTime.plusMonths(1).minusMillis(1).getMillis());
                case 5:
                    return new Interval(dateTime.getMillis(), dateTime.plusYears(1).minusMillis(1).getMillis());
                }
            }
        } catch (Exception e) {
        }
    }
    return null;
}

From source file:Implement.DAO.BookingDAOImpl.java

@Override
public void insertOfflineEngineBooking(String bookingDate, String tripDate, String tripTime, int noPackage,
        int packageID, String resourceNote, String customerName, String customerPhone, String customerEmail,
        String durationType, int duration, int smallestInterval, int providerID) {

    //  construct dynamic sql for used resources
    DateTimeFormatter formatterDateAndHour = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss");
    String travelTimeStr = tripDate;
    if (!durationType.equals("days")) {
        travelTimeStr += " " + tripTime + ":00";
    } else {//  w  w w  . j  a v  a  2 s .  c o m
        travelTimeStr += " 00:00:00";
    }
    DateTime travelTime = formatterDateAndHour.parseDateTime(travelTimeStr);
    DateTime endTime = new DateTime(travelTime);

    if (!durationType.equals("days")) {
        // change hours to minutes
        if (durationType.equals("hours")) {
            duration *= 60;
        }
        travelTime = travelTime.minusMinutes(duration);
        endTime = endTime.plusMinutes(duration);
    } else {
        travelTime = travelTime.minusDays(duration - 1);
        endTime = endTime.plusDays(duration + 1);
    }

    // loop each 5 minutes
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("MM/dd/YYYY");
    DateTimeFormatter fmtTime = DateTimeFormat.forPattern("HH:mm");
    String valueStr = "VALUES ";
    DateTime eachTime = new DateTime(travelTime);
    String date = fmtDate.print(eachTime);
    String time = fmtTime.print(eachTime);
    valueStr += " (@ResourceIDVar,'" + date + "','" + time + "',@NoUsedResourcesVar, @providerIDVar)";
    eachTime = eachTime.plusMinutes(smallestInterval);
    while (eachTime.isBefore(endTime)) {
        date = fmtDate.print(eachTime);
        time = fmtTime.print(eachTime);
        valueStr += ",(@ResourceIDVar,'" + date + "','" + time + "',@NoUsedResourcesVar, @providerIDVar)";
        eachTime = eachTime.plusMinutes(smallestInterval);
    }

    String insertStmt = "INSERT INTO UsedResources(ResourceID, TripDate, TripTime, NoUsedResources, ProviderID) ";
    insertStmt += valueStr;

    // Build Param Condition For Procedure
    String paramCondition = "@ResourceIDVar INT, @NoUsedResourcesVar INT, @providerIDVar INT";

    simpleJdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("InsertOfflineBooking");
    SqlParameterSource in = new MapSqlParameterSource().addValue("bookingDate", bookingDate)
            .addValue("providerID", providerID).addValue("tripDate", tripDate).addValue("tripTime", tripTime)
            .addValue("noPackage", noPackage).addValue("packageID", packageID)
            .addValue("resourceNote", resourceNote).addValue("customerName", customerName)
            .addValue("customerPhone", customerPhone).addValue("customerEmail", customerEmail)
            .addValue("InsertStatement", insertStmt).addValue("ParmDefinition", paramCondition);
    simpleJdbcCall.execute(in);
}

From source file:io.github.protino.codewatch.ui.GoalsDetailFragment.java

License:Apache License

private BarData generateBarData(int dailyGoal, List<Integer> progressSoFar) {

    ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());

    DateTime dateTime = new DateTime();
    referenceTime = dateTime.minusDays(7).getMillis();
    for (int i = 0; i < progressSoFar.size(); i++) {
        barEntries.add(new BarEntry(i, progressSoFar.get(i)));
    }//from   w w  w .j  a va2  s  .c o  m

    BarDataSet barDataSet = new BarDataSet(barEntries, "");

    int colors[] = new int[progressSoFar.size()];
    for (int i = 0; i < progressSoFar.size(); i++) {
        colors[i] = (progressSoFar.get(i) >= dailyGoal * 60 * 60) ? green400 : red400;
    }
    barDataSet.setColors(colors);

    BarData barData = new BarData(barDataSet);
    barData.setBarWidth(0.85f);
    barData.setDrawValues(false);
    return barData;
}

From source file:io.github.protino.codewatch.ui.ProjectDetailsFragment.java

License:Apache License

private BarData generateBarData(List<Integer> progressSoFar) {

    ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());

    DateTime dateTime = new DateTime();
    referenceTime = dateTime.minusDays(7).getMillis();
    int totalSeconds = 0;
    for (int i = 0; i < progressSoFar.size(); i++) {
        int progress = progressSoFar.get(i);
        barEntries.add(new BarEntry(i, progress));
        totalSeconds += progress;/*from   w ww  .  j  a va2 s  . c o  m*/
    }

    activityTotal.setText(context.getString(R.string.total_project_time,
            FormatUtils.getFormattedTime(context, totalSeconds)));

    BarDataSet barDataSet = new BarDataSet(barEntries, "");

    barDataSet.setColors(blue400);

    BarData barData = new BarData(barDataSet);
    barData.setBarWidth(0.85f);
    barData.setDrawValues(false);
    return barData;
}

From source file:it.cineca.pst.huborcid.service.UserService.java

License:Open Source License

/**
 * Not activated users should be automatically deleted after 3 days.
 * <p/>/*from w ww .  ja va2s  .  co m*/
 * <p>
 * This is scheduled to get fired everyday, at 01:00 (am).
 * </p>
 */
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
    DateTime now = new DateTime();
    List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
    for (User user : users) {
        log.debug("Deleting not activated user {}", user.getLogin());
        userRepository.delete(user);
    }
}

From source file:it.geosolutions.geobatch.destination.common.utils.TimeUtils.java

License:Open Source License

/**
 * @return start time (one day ago)//from ww w  .  j a  v  a 2  s .  c om
 */
public static DateTime getTodayStart() {
    DateTime now = new DateTime();
    return now.minusDays(1);
}

From source file:it.jugpadova.blo.EventBo.java

License:Apache License

public List<NewsMessage> buildNewsMessages(String baseUrl) {
    List<NewsMessage> messages = new ArrayList<NewsMessage>();
    DateTime dt = new DateTime();
    List<Event> upcomings = eventDao.findUpcomingEvents(dt.plusDays(conf.getUpcomingEventDays()).toDate());
    for (Event event : upcomings) {
        messages.add(new NewsMessage(NewsMessage.TYPE_UPCOMING_EVENT, event.getStartDate(), event, baseUrl));
    }/*from  w  w w.  j a v a 2s.  c  om*/
    List<Event> newEvents = eventDao.findNewEvents(dt.minusDays(conf.getNewEventDays()).toDate());
    for (Event event : newEvents) {
        if (!upcomings.contains(event)) {
            messages.add(new NewsMessage(NewsMessage.TYPE_NEW_EVENT, event.getStartDate(), event, baseUrl));
        }
    }
    List<LinkedEvent> linkedEvents = linkedEventDao.findExposedEvents();
    for (LinkedEvent linkedEvent : linkedEvents) {
        messages.add(new NewsMessage(NewsMessage.TYPE_LINKED_EVENT, linkedEvent.getStartDate(), linkedEvent,
                baseUrl));
    }
    return messages;
}

From source file:javaapplication1.GenerateTest2DK.java

public static void main(String[] args) throws IOException {
    int episodeNumber = 0;
    BufferedReader buffreader = null;
    try {/*from   ww w .  j a v  a2  s.  c  o  m*/
        // open the file for reading
        InputStream fis = new FileInputStream("kuasha-episode.txt");

        // if file the available for reading
        if (fis != null) {

            // prepare the file for reading
            InputStreamReader chapterReader = new InputStreamReader(fis);
            buffreader = new BufferedReader(chapterReader);

            String line = null;
            while (true) {
                try {
                    line = buffreader.readLine();

                } catch (Exception e) {

                }

                if (line == null)
                    break;

                songPath.add(line);
                episodeNumber++;
            }

            /*String line;
                    
            // read every line of the file into the line-variable, on line at the time
            do {
               line = buffreader.readLine();
              // do something with the line 
               System.out.println(line);
            } while (line != null);
              */

        }
    } catch (Exception e) {

    } finally {

    }

    String[] monthStr2 = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nove",
            "Dec" };

    String[] monthStr = { "January", "February", "March", "April", "May", "June", "July", "August", "September",
            "October", "November", "December" };

    String[] urlImage = { "http://i.imgur.com/Pks8tmU.jpg", "http://i.imgur.com/UHv8tdw.jpg",
            "http://i.imgur.com/AybMRiN.jpg", "http://i.imgur.com/J7gMxN4.jpg",
            "http://i.imgur.com/8C3N9lN.jpg", "http://i.imgur.com/p5RjLUq.jpg", "http://i.imgur.com/vp97ZQe.jpg"

    };

    List<DateTime> fridays = new ArrayList<>();
    boolean reachedAFriday = false;

    String start = "12/08/2010";
    String end = "01/02/2011";
    DateTimeFormatter pattern = DateTimeFormat.forPattern("dd/mm/yyyy");
    DateTime startDate = new DateTime();//(2018, 06, 22, 0, 0, 0, 0);//pattern.parseDateTime(start); // year-month-day
    DateTime endDate = new DateTime(2010, 1, 1, 0, 0, 0, 0);//pattern.parseDateTime(end);

    int startRange = 0;
    int yearID = 0;
    int albumID = 0;
    int songID = 0;

    String url = "{\"albumList\":[";
    String prevYear = "";

    Random r = new Random();
    int i1 = (r.nextInt(80) + 65);
    while (startDate.isAfter(endDate)) {
        if (songID >= episodeNumber)
            break;
        String dayOfYaer = "" + startDate.getYear();

        if (!prevYear.equals(dayOfYaer)) {
            url += "{\"yearID\":\"" + yearID + "\", \"yearName\":\"" + "YEAR-" + dayOfYaer
                    + "\", \"monthList\":[";
            prevYear = "" + startDate.getYear();
            yearID++;
        }

        String dayOfMonth = "" + monthStr[startDate.getMonthOfYear() - 1];
        url += "{\"albumID\":\"" + albumID + "\", \"albumName\":\"" + "" + dayOfMonth + "\", \"songList\":["; //+"Month-"+startDate.dayOfMonth() +"\"},";
        //System.out.println("fahad -- "+ (startDate.getDayOfMonth()-1));
        if (startRange == 0)
            startRange = songID;
        while ((monthStr[startDate.getMonthOfYear() - 1]).equals(dayOfMonth)) {
            if (songID >= episodeNumber)
                break;
            if (startDate.getDayOfWeek() == DateTimeConstants.MONDAY) {
                fridays.add(startDate);
                reachedAFriday = true;

                String MothWithTwoDigit = String.format("%02d", startDate.getMonthOfYear());
                String dateWithTwoDigit = String.format("%02d", startDate.getDayOfMonth());

                String date = startDate.getYear() + "-" + MothWithTwoDigit + "-" + dateWithTwoDigit;
                String EpisodesName = "Ep-" + dateWithTwoDigit + " " + monthStr2[startDate.getMonthOfYear() - 1]
                        + "," + startDate.getYear();
                if (songID == 0)
                    EpisodesName = "(New)" + EpisodesName;

                path = songPath.get(episodeNumber - songID - 1);//"http://dl.bhoot-fm.com/Bhoot-FM_"+date+"_(Bhoot-FM.com).mp3";
                artist = "Kuasha";
                composer = "ABC-Radio";
                imageUrl = urlImage[r.nextInt(7)];//"http://3.bp.blogspot.com/-nd09lbpK1Mk/U7hkntBHF4I/AAAAAAAAAM8/FFsAfjT9tW8/s1600/bhoot.jpg";

                url += "{\"songID\":\"" + songID + "\", \"title\":\"" + EpisodesName + "\", \"artist\":\""
                        + artist + "\", \"path\":\"" + path + "\", \"albumId\":\"" + albumID
                        + "\", \"composer\":\"" + composer + "\", \"imageUrl\":\"" + imageUrl + "\"},";

                songID++;
            }
            if (reachedAFriday) {
                startDate = startDate.minusWeeks(1);
            } else {
                startDate = startDate.minusDays(1);
            }

            System.out.println("fahad -- " + (startDate.getDayOfMonth() - 1));
        }

        albumID++;
        url = url.substring(0, url.length() - 1) + "], \"songListRange\":\"" + startRange + "-" + (songID - 1)
                + "\"},";

        startRange = 0;

        if (!prevYear.equals("" + startDate.getYear())) {
            url = url.substring(0, url.length() - 1) + "]},";
            //prevYear = dayOfYaer;
        }
    }

    url = url.substring(0, url.length() - 1) + "]}]}";//]}
    System.out.println(url);

    File file = new File("filename_kuasha.txt");

    // if file doesnt exists, then create it
    if (!file.exists()) {
        file.createNewFile();
    }

    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(url);
    bw.close();

    System.out.println("Done");

}

From source file:javaapplication1.GenerateTest2Dor.java

public static void main(String[] args) throws IOException {
    BufferedReader buffreader = null;
    try {//  w w w  . ja  va2  s.c  o  m
        // open the file for reading
        InputStream fis = new FileInputStream("Dor.txt");

        // if file the available for reading
        if (fis != null) {

            // prepare the file for reading
            InputStreamReader chapterReader = new InputStreamReader(fis);
            buffreader = new BufferedReader(chapterReader);

            String line = null;
            while (true) {
                try {
                    line = buffreader.readLine();

                } catch (Exception e) {

                }

                if (line == null)
                    break;

                songPath.add(line);

            }

            /*String line;
                    
            // read every line of the file into the line-variable, on line at the time
            do {
               line = buffreader.readLine();
              // do something with the line 
               System.out.println(line);
            } while (line != null);
              */

        }
    } catch (Exception e) {

    } finally {

    }

    String[] monthStr2 = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nove",
            "Dec" };

    String[] monthStr = { "January", "February", "March", "April", "May", "June", "July", "August", "September",
            "October", "November", "December" };

    String[] urlImage = { "http://i.imgur.com/DMmPf5f.jpg", "http://i.imgur.com/8C3N9lN.jpg",
            "http://i.imgur.com/MGQSXb1.jpg", "http://i.imgur.com/nyv8gOD.jpg",
            "http://i.imgur.com/kzr9p5M.jpg", "http://i.imgur.com/nBTPbty.jpg", "http://i.imgur.com/VvLI4sY.jpg"

    };

    List<DateTime> fridays = new ArrayList<>();
    boolean reachedAFriday = false;

    String start = "12/08/2010";
    String end = "01/02/2011";
    DateTimeFormatter pattern = DateTimeFormat.forPattern("dd/mm/yyyy");
    DateTime startDate = new DateTime(2018, 03, 03, 0, 0, 0, 0);//pattern.parseDateTime(start); // year-month-day
    DateTime endDate = new DateTime(2010, 1, 1, 0, 0, 0, 0);//pattern.parseDateTime(end);

    int startRange = 0;
    int yearID = 0;
    int albumID = 0;
    int songID = 0;
    int episodeNumber = 172;
    String url = "{\"albumList\":[";
    String prevYear = "";

    Random r = new Random();
    int i1 = (r.nextInt(80) + 65);
    while (startDate.isAfter(endDate)) {
        if (songID >= episodeNumber)
            break;
        String dayOfYaer = "" + startDate.getYear();

        if (!prevYear.equals(dayOfYaer)) {
            url += "{\"yearID\":\"" + yearID + "\", \"yearName\":\"" + "YEAR-" + dayOfYaer
                    + "\", \"monthList\":[";
            prevYear = "" + startDate.getYear();
            yearID++;
        }

        String dayOfMonth = "" + monthStr[startDate.getMonthOfYear() - 1];
        url += "{\"albumID\":\"" + albumID + "\", \"albumName\":\"" + "" + dayOfMonth + "\", \"songList\":["; //+"Month-"+startDate.dayOfMonth() +"\"},";
        //System.out.println("fahad -- "+ (startDate.getDayOfMonth()-1));
        if (startRange == 0)
            startRange = songID;
        while ((monthStr[startDate.getMonthOfYear() - 1]).equals(dayOfMonth)) {
            if (songID >= episodeNumber)
                break;
            if (startDate.getDayOfWeek() == DateTimeConstants.THURSDAY) {
                fridays.add(startDate);
                reachedAFriday = true;

                String MothWithTwoDigit = String.format("%02d", startDate.getMonthOfYear());
                String dateWithTwoDigit = String.format("%02d", startDate.getDayOfMonth());

                String date = startDate.getYear() + "-" + MothWithTwoDigit + "-" + dateWithTwoDigit;
                String EpisodesName = "Ep-" + dateWithTwoDigit + " " + monthStr2[startDate.getMonthOfYear() - 1]
                        + "," + startDate.getYear();
                if (songID == 0)
                    EpisodesName = "(New)" + EpisodesName;

                path = songPath.get(episodeNumber - songID - 1);//"http://dl.bhoot-fm.com/Bhoot-FM_"+date+"_(Bhoot-FM.com).mp3";
                artist = "Dor";
                composer = "ABC-Radio";
                imageUrl = urlImage[r.nextInt(7)];//"http://3.bp.blogspot.com/-nd09lbpK1Mk/U7hkntBHF4I/AAAAAAAAAM8/FFsAfjT9tW8/s1600/bhoot.jpg";

                url += "{\"songID\":\"" + songID + "\", \"title\":\"" + EpisodesName + "\", \"artist\":\""
                        + artist + "\", \"path\":\"" + path + "\", \"albumId\":\"" + albumID
                        + "\", \"composer\":\"" + composer + "\", \"imageUrl\":\"" + imageUrl + "\"},";

                songID++;
            }
            if (reachedAFriday) {
                startDate = startDate.minusWeeks(1);
            } else {
                startDate = startDate.minusDays(1);
            }

            System.out.println("fahad -- " + (startDate.getDayOfMonth() - 1));
        }

        albumID++;
        url = url.substring(0, url.length() - 1) + "], \"songListRange\":\"" + startRange + "-" + (songID - 1)
                + "\"},";

        startRange = 0;

        if (!prevYear.equals("" + startDate.getYear())) {
            url = url.substring(0, url.length() - 1) + "]},";
            //prevYear = dayOfYaer;
        }
    }

    url = url.substring(0, url.length() - 1) + "]}]}";//]}
    System.out.println(url);

    File file = new File("filename_dor.txt");

    // if file doesnt exists, then create it
    if (!file.exists()) {
        file.createNewFile();
    }

    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(url);
    bw.close();

    System.out.println("Done");

}

From source file:javaapplication1.GenerateTest2JibonerGolpo.java

public static void main(String[] args) throws IOException {
    int episodeNumber = 0;
    BufferedReader buffreader = null;
    try {/* ww w .j  a v  a 2 s.  com*/
        // open the file for reading
        InputStream fis = new FileInputStream("api_jibon/Jiboner_Golpo.txt");

        // if file the available for reading
        if (fis != null) {

            // prepare the file for reading
            InputStreamReader chapterReader = new InputStreamReader(fis);
            buffreader = new BufferedReader(chapterReader);

            String line = null;
            while (true) {
                try {
                    line = buffreader.readLine();

                } catch (Exception e) {

                }

                if (line == null)
                    break;
                songPath.add(line);
                episodeNumber++;

            }

            /*String line;
                    
            // read every line of the file into the line-variable, on line at the time
            do {
               line = buffreader.readLine();
              // do something with the line 
               System.out.println(line);
            } while (line != null);
              */

        }
    } catch (Exception e) {

    } finally {

    }

    String[] monthStr2 = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nove",
            "Dec" };

    String[] monthStr = { "January", "February", "March", "April", "May", "June", "July", "August", "September",
            "October", "November", "December" };

    String[] urlImage = { "https://i.imgur.com/VAwVL2V.jpg", "https://i.imgur.com/bvWyY1t.jpg",
            "https://i.imgur.com/VAwVL2V.jpg", "https://i.imgur.com/bvWyY1t.jpg",
            "https://i.imgur.com/VAwVL2V.jpg", "https://i.imgur.com/bvWyY1t.jpg",
            "https://i.imgur.com/VAwVL2V.jpg"

    };

    List<DateTime> fridays = new ArrayList<>();
    boolean reachedAFriday = false;

    String start = "12/08/2010";
    String end = "01/02/2011";
    DateTimeFormatter pattern = DateTimeFormat.forPattern("dd/mm/yyyy");
    DateTime startDate = new DateTime();//(2018, 06, 16, 0, 0, 0, 0);//pattern.parseDateTime(start); // year-month-day
    DateTime endDate = new DateTime(2010, 1, 1, 0, 0, 0, 0);//pattern.parseDateTime(end);

    int startRange = 0;
    int yearID = 0;
    int albumID = 0;
    int songID = 0;

    String url = "{\"albumList\":[";
    String prevYear = "";

    Random r = new Random();
    int i1 = (r.nextInt(80) + 65);
    while (startDate.isAfter(endDate)) {
        if (songID >= episodeNumber)
            break;
        String dayOfYaer = "" + startDate.getYear();

        if (!prevYear.equals(dayOfYaer)) {
            url += "{\"yearID\":\"" + yearID + "\", \"yearName\":\"" + "YEAR-" + dayOfYaer
                    + "\", \"monthList\":[";
            prevYear = "" + startDate.getYear();
            yearID++;
        }

        String dayOfMonth = "" + monthStr[startDate.getMonthOfYear() - 1];
        url += "{\"albumID\":\"" + albumID + "\", \"albumName\":\"" + "" + dayOfMonth + "\", \"songList\":["; //+"Month-"+startDate.dayOfMonth() +"\"},";
        //System.out.println("fahad -- "+ (startDate.getDayOfMonth()-1));
        if (startRange == 0)
            startRange = songID;
        while ((monthStr[startDate.getMonthOfYear() - 1]).equals(dayOfMonth)) {
            if (songID >= episodeNumber)
                break;
            if (startDate.getDayOfWeek() == DateTimeConstants.WEDNESDAY) {
                fridays.add(startDate);
                reachedAFriday = true;

                String MothWithTwoDigit = String.format("%02d", startDate.getMonthOfYear());
                String dateWithTwoDigit = String.format("%02d", startDate.getDayOfMonth());

                String date = startDate.getYear() + "-" + MothWithTwoDigit + "-" + dateWithTwoDigit;
                String EpisodesName = "Ep-" + dateWithTwoDigit + " " + monthStr2[startDate.getMonthOfYear() - 1]
                        + "," + startDate.getYear();
                if (songID == 0)
                    EpisodesName = "(New)" + EpisodesName;

                path = songPath.get(episodeNumber - songID - 1);//"http://dl.bhoot-fm.com/Bhoot-FM_"+date+"_(Bhoot-FM.com).mp3";

                String performaerName = "";
                if (path != null) {
                    System.out.println("" + path);

                    String splitedName[] = path.split("-");

                    performaerName = splitedName[splitedName.length - 1].substring(0,
                            splitedName[splitedName.length - 1].length() - 17);
                    EpisodesName = EpisodesName + "-" + performaerName;
                }

                artist = "Jiboner Golpo";
                composer = "ABC-Radio";
                imageUrl = urlImage[r.nextInt(7)];//"http://3.bp.blogspot.com/-nd09lbpK1Mk/U7hkntBHF4I/AAAAAAAAAM8/FFsAfjT9tW8/s1600/bhoot.jpg";

                url += "{\"songID\":\"" + songID + "\", \"title\":\"" + EpisodesName + "\", \"artist\":\""
                        + artist + "\", \"path\":\"" + path + "\", \"albumId\":\"" + albumID
                        + "\", \"composer\":\"" + composer + "\", \"imageUrl\":\"" + imageUrl + "\"},";

                songID++;
            }
            if (reachedAFriday) {
                startDate = startDate.minusWeeks(1);
            } else {
                startDate = startDate.minusDays(1);
            }

            System.out.println("fahad -- " + (startDate.getDayOfMonth() - 1));
        }

        albumID++;
        url = url.substring(0, url.length() - 1) + "], \"songListRange\":\"" + startRange + "-" + (songID - 1)
                + "\"},";

        startRange = 0;

        if (!prevYear.equals("" + startDate.getYear())) {
            url = url.substring(0, url.length() - 1) + "]},";
            //prevYear = dayOfYaer;
        }
    }

    url = url.substring(0, url.length() - 1) + "]}]}";//]}
    System.out.println(url);

    File file = new File("api_jibon/filename_jiboner_golpo.json");

    // if file doesnt exists, then create it
    if (!file.exists()) {
        file.createNewFile();
    }

    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(url);
    bw.close();

    System.out.println("Done");

}