List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:javaapplication1.GenerateTest2JibonerGolpo.java
public static void main(String[] args) throws IOException { int episodeNumber = 0; BufferedReader buffreader = null; try {//from www.ja v a2 s . co m // 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());//ww w. j a v a2 s. co m 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.timeperiod.TimeCalendar.java
License:Apache License
@Override public int getDayOfMonth(DateTime time) { return time.getDayOfMonth(); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** * ? ?? ?(Day) true false ./*from w w w. j ava 2 s .c om*/ * * @param left the left * @param right the right * @return the boolean */ public static boolean isSameDay(DateTime left, DateTime right) { return isSameMonth(left, right) && left.getDayOfMonth() == right.getDayOfMonth(); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ??? ? . */ public static DateTime setYear(DateTime moment, int year) { return setDate(moment, year, moment.getMonthOfYear(), moment.getDayOfMonth()); }
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** ??? . */ public static DateTime setMonth(DateTime moment, int monthOfYear) { return setDate(moment, moment.getYear(), monthOfYear, moment.getDayOfMonth()); }
From source file:li.klass.fhem.adapter.devices.core.generic.detail.actions.devices.fht.HolidayShort.java
License:Open Source License
public void showDialog(final Context context, final ViewGroup parent, final LayoutInflater layoutInflater, final SpinnerActionRow spinnerActionRow, final XmlListDevice device, final Intent switchIntent) { final DateTime now = dateService.now(); final TableLayout contentView = (TableLayout) handleColorStateBug(new AndroidBug.BugHandler() { @Override/*from w w w .ja v a2 s. c o m*/ public View bugEncountered() { final TableLayout contentView = (TableLayout) layoutInflater .inflate(R.layout.fht_holiday_short_dialog_android_bug, parent, false); final FallbackTimePicker timePicker = (FallbackTimePicker) contentView .findViewById(R.id.timePicker); timePicker.setMinutes(0); timePicker.setHours(now.getHourOfDay()); timePicker.setOnValueChangedListener(new FallbackTimePicker.OnValueChangedListener() { @Override public void onValueChanged(int hours, int minutes) { HolidayShort.this.hour = hours; HolidayShort.this.minute = minutes; updateHolidayShortEndTime(contentView); } }); return contentView; } @Override public View defaultAction() { final TableLayout contentView = (TableLayout) layoutInflater .inflate(R.layout.fht_holiday_short_dialog, parent, false); final TimePicker timePicker = (TimePicker) contentView.findViewById(R.id.timePicker); timePicker.setIs24HourView(true); timePicker.setCurrentMinute(0); timePicker.setCurrentHour(now.getHourOfDay()); timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { @Override public void onTimeChanged(TimePicker timePicker, int hourOfDay, int minute) { HolidayShort.this.hour = hourOfDay; HolidayShort.this.minute = minute; updateHolidayShortEndTime(contentView); } }); return contentView; } }); updateHolidayShortEndTime(contentView); final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); TableRow temperatureUpdateRow = (TableRow) contentView.findViewById(R.id.updateTemperatureRow); final TemperatureChangeTableRow temperatureChangeTableRow = new TemperatureChangeTableRow(context, MINIMUM_TEMPERATURE, temperatureUpdateRow, MINIMUM_TEMPERATURE, MAXIMUM_TEMPERATURE, applicationProperties); contentView.addView(temperatureChangeTableRow.createRow(layoutInflater, device)); dialogBuilder.setNegativeButton(R.string.cancelButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { spinnerActionRow.revertSelection(); dialogInterface.dismiss(); } }); dialogBuilder.setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int item) { DateTime switchDate = holiday1SwitchTimeFor(hour, minute); @SuppressWarnings("unchecked") List<StateToSet> states = (List<StateToSet>) switchIntent .getSerializableExtra(BundleExtraKeys.STATES); states.add(new StateToSet("desired-temp", "" + temperatureChangeTableRow.getTemperature())); states.add(new StateToSet("holiday1", "" + extractHolidayShortHoliday1ValueFrom(switchDate))); states.add(new StateToSet("holiday2", "" + switchDate.getDayOfMonth())); context.startService(switchIntent); spinnerActionRow.commitSelection(); dialogInterface.dismiss(); } }); dialogBuilder.setView(contentView); dialogBuilder.show(); }
From source file:li.klass.fhem.adapter.devices.core.generic.detail.actions.devices.fht.HolidayShort.java
License:Open Source License
DateTime holiday1SwitchTimeFor(int hourOfDay, int minute) { int newMinute = (int) ((Math.round(minute / 10.0) * 10) % 60); if (newMinute == 0) { hourOfDay += minute > 30 ? 1 : 0; }//from w ww . j av a 2 s . c om hourOfDay %= 24; DateTime now = dateService.now(); DateTime switchTime = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), hourOfDay, newMinute); if (holidayShortIsTomorrow(switchTime, now)) { switchTime = switchTime.plusDays(1); } return switchTime; }
From source file:lucee.commons.date.JodaDateTimeUtil.java
License:Open Source License
@Override public String toString(lucee.runtime.type.dt.DateTime date, TimeZone tz) { //return jreUtil.toString(date, tz); /*DateTime dt = new DateTime(date.getTime(),getDateTimeZone(tz)); return "{ts '"+dt.getYear()+//from www . ja v a 2 s. c om "-"+dt.getMonthOfYear()+ "-"+dt.getDayOfMonth()+ " "+dt.getHourOfDay()+ ":"+dt.getMinuteOfHour()+ ":"+dt.getSecondOfMinute()+"'}";*/ StringBuilder sb = new StringBuilder(); DateTime dt = new DateTime(date.getTime(), getDateTimeZone(tz)); sb.append("{ts '"); jreUtil.toString(sb, dt.getYear(), 4); sb.append("-"); jreUtil.toString(sb, dt.getMonthOfYear(), 2); sb.append("-"); jreUtil.toString(sb, dt.getDayOfMonth(), 2); sb.append(" "); jreUtil.toString(sb, dt.getHourOfDay(), 2); sb.append(":"); jreUtil.toString(sb, dt.getMinuteOfHour(), 2); sb.append(":"); jreUtil.toString(sb, dt.getSecondOfMinute(), 2); sb.append("'}"); return sb.toString(); }