Example usage for org.joda.time DateTime getMonthOfYear

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

Introduction

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

Prototype

public int getMonthOfYear() 

Source Link

Document

Get the month of year field value.

Usage

From source file:it.fabaris.wfp.widget.DateTimeWidget.java

License:Open Source License

/**
 * set the answer to the answer Widget/*from w ww  .j a v  a  2s  . co  m*/
 * getting in it from the FormEntryPrompt
 * otherwise create time widget with
 * the current time
 */
private void setAnswer() {

    if (mPrompt.getAnswerValue() != null) {
        DateTime ldt = new DateTime(((Date) ((DateTimeData) mPrompt.getAnswerValue()).getValue()).getTime());
        //mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
        //LA DATA DI SINCRONIZZAZIONE ERA SETTATA CON UN MESE INDIETRO
        mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear(), ldt.getDayOfMonth(), mDateListener);
        mTimePicker.setCurrentHour(ldt.getHourOfDay());
        mTimePicker.setCurrentMinute(ldt.getMinuteOfHour());

    } else {
        // create time widget with current time as of right now
        clearAnswer();
    }
}

From source file:it.fabaris.wfp.widget.DateWidget.java

License:Open Source License

/**
 * if there is an answer in the FormEntryPrompt
 * put it in the answer Widget, clean//w w w .  j  a  v  a 2  s.c om
 * the widget value otherwise
 */
private void setAnswer() {

    if (mPrompt.getAnswerValue() != null) {
        DateTime ldt = new DateTime(((Date) ((DateData) mPrompt.getAnswerValue()).getValue()).getTime());
        mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
        //mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
    } else {
        // create date widget with current time as of right now
        clearAnswer();
    }
}

From source file:it.fabaris.wfp.widget.DateWidget.java

License:Open Source License

/**
 * Resets date to today.//from   w w w. j a v a 2 s  . c  o  m
 */
@Override
public void clearAnswer() {
    DateTime ldt = new DateTime();
    mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
    //mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
}

From source file:it.mazzoni.twilight.Twilight.java

License:Open Source License

private boolean updateData() {
    DateTime dt = new DateTime();
    int dst = dt.getZone().isStandardOffset(dt.getMillis()) ? 0 : 1;
    int offset = dt.getZone().getStandardOffset(dt.getMillis()) / 3600000;
    //LOG.log(Level.INFO, "Current TIME: {0}/{1} {2} DST: {3}", new Object[]{dt.getDayOfMonth(), dt.getMonthOfYear(), offset, dst});
    Document doc = getXMLStatusFile(dt.getDayOfMonth(), dt.getMonthOfYear(), offset, dst);
    //parse xml // w  w w .jav  a2s .c  om
    if (doc != null) {
        Node sunriseNode = doc.getElementsByTagName("sunrise").item(0);
        Node sunsetNode = doc.getElementsByTagName("sunset").item(0);
        // compara con l'ora attuale
        String srTime[] = sunriseNode.getFirstChild().getNodeValue().split(":");
        String ssTime[] = sunsetNode.getFirstChild().getNodeValue().split(":");
        TLU.setSunriseTime(new DateTime(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(),
                Integer.parseInt(srTime[0]), Integer.parseInt(srTime[1]), Integer.parseInt(srTime[2])));
        TLU.setSunsetTime(new DateTime(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(),
                Integer.parseInt(ssTime[0]), Integer.parseInt(ssTime[1]), Integer.parseInt(ssTime[2])));
        LOG.log(Level.INFO, "Sunrise at: {0} Sunset at:{1}",
                new Object[] { TLU.getSunriseTime(), TLU.getSunsetTime() });

        return true;
    } else {
        return false;
    }
}

From source file:javaapplication1.GenerateTest2DK.java

public static void main(String[] args) throws IOException {
    int episodeNumber = 0;
    BufferedReader buffreader = null;
    try {//from  w  w w. j  a  v  a  2  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 ww . j a  v a  2s  .com*/
        // 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 {//from  w  w  w .ja va 2  s.  c  om
        // 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");

}

From source file:jtodo.ui.TaskEditorWindow.java

License:Open Source License

private void fillInValues() {
    logger.log(Level.INFO, "Automatically filling in the values for the task");

    fieldName.setText(task.getName());/*w ww  .  j  a v a2s.c  om*/
    fieldDescription.setText(task.getDescription());
    comboBoxPriority.setSelectedItem(task.getPriority());

    if (task.isDeadlineActive()) {

        DateTime dateTime = task.getDeadline().getDateTime();

        comboBoxDay.setSelectedIndex(dateTime.getDayOfMonth() - 1);
        comboBoxMonth.setSelectedIndex(dateTime.getMonthOfYear() - 1);
        fieldYear.setText("" + dateTime.getYear());
        comboBoxTime.setSelectedItem(dateTime.getHourOfDay() + ":" + dateTime.getMinuteOfHour());

        checkBoxDeadlineActive.setSelected(true);
    } else {
        checkBoxDeadlineActive.setSelected(false);
        setDateSelectionEnabledIfCheckBoxActive();
    }

}

From source file:julian.lylly.model.Util.java

public static String dateTimeToString(DateTime dt) {
    String y = dt.getYear() + "";
    String m = longTo2DigitString(dt.getMonthOfYear());
    String d = longTo2DigitString(dt.getDayOfMonth());
    String h = longTo2DigitString(dt.getHourOfDay());
    String mi = longTo2DigitString(dt.getMinuteOfHour());
    return y + "-" + m + "-" + d + " " + h + ":" + mi;
}

From source file:kr.debop4j.core.tools.DateTool.java

License:Apache License

/**
 * Gets start of month./*  ww  w  . j  a  v  a  2 s  . c o m*/
 *
 * @param moment the moment
 * @return the start of month
 */
public static DateTime getStartOfMonth(final DateTime moment) {
    return new DateTime().withDate(moment.getYear(), moment.getMonthOfYear(), 1);
}