List of usage examples for java.util Date getMonth
@Deprecated public int getMonth()
From source file:org.openmrs.module.DeIdentifiedPatientDataExportModule.api.impl.DeIdentifiedExportServiceImpl.java
private List<Encounter> randomizeEncounterDates(List<Obs> patientObsList) { Integer flag = 0;/*from w w w .j a va 2 s . c o m*/ List<Date> randomizedEncounterDateList = new ArrayList<Date>(); List<Encounter> en = new ArrayList<Encounter>(); for (Obs o : patientObsList) { en.add(o.getEncounter()); } int year, month, date; try { for (int i = 0; i < patientObsList.size(); i++) { Date d = new Date(); if (flag == 0) { d.setDate(en.get(0).getEncounterDatetime().getDate()); d.setMonth(en.get(0).getEncounterDatetime().getMonth()); d.setYear(en.get(0).getEncounterDatetime().getYear()); flag = 1; } else { d.setDate(en.get(i - 1).getEncounterDatetime().getDate()); d.setMonth(en.get(i - 1).getEncounterDatetime().getMonth()); d.setYear(en.get(i - 1).getEncounterDatetime().getYear()); } year = d.getYear() + 1900; month = d.getMonth(); date = d.getDate(); //Randomize year = randBetween(year + 1, year + 2); month = randBetween(month, 12); date = randBetween(date, 30); //Set date d.setYear(year - 1900); d.setMonth(month); d.setDate(date); en.get(i).setEncounterDatetime(d); randomizedEncounterDateList.add(d); } } catch (APIException e) { log.error("Exception in randomizing encounter dates", e); } return en; }
From source file:com.ridgelineapps.wallpaper.photosite.FlickrUtils.java
String formatDate(Date date) { date = new Date(date.getTime() - (1000 * 60 * 60 * 24)); String year = "" + (date.getYear() + 1900); String month = "" + (date.getMonth() + 1); String day = "" + (date.getDate()); if (month.length() < 2) { month = "0" + month; }/* www . j ava2 s . c o m*/ if (day.length() < 2) { day = "0" + day; } return year + "-" + month + "-" + day; }
From source file:com.krawler.esp.servlets.importProjectPlanCSV.java
public String getActualDuration(Date stdate, Date enddate, int[] NonWorkDays, String[] holidays) { int noofdays = 0; java.text.SimpleDateFormat sdf1 = new java.text.SimpleDateFormat("yyyy-MM-dd"); try {/*w w w .j a v a 2 s . com*/ Calendar c1 = Calendar.getInstance(); while (stdate.compareTo(enddate) < 0) { if (Arrays.binarySearch(NonWorkDays, stdate.getDay()) < 0 && Arrays.binarySearch(holidays, sdf1.format(stdate)) < 0) { noofdays++; } c1.set(stdate.getYear() + 1900, stdate.getMonth(), stdate.getDate()); c1.add(Calendar.DATE, 1); stdate = sdf1.parse(sdf1.format(c1.getTime())); } if (stdate.compareTo(enddate) == 0) { if (Arrays.binarySearch(NonWorkDays, stdate.getDay()) < 0 && Arrays.binarySearch(holidays, sdf1.format(stdate)) < 0) { noofdays++; } } } catch (ParseException ex) { Logger.getLogger(importProjectPlanCSV.class.getName()).log(Level.SEVERE, null, ex); } return noofdays + "d"; }
From source file:com.homeworkreminder.Main.java
@SuppressWarnings("deprecation") private static boolean initInfoListForDate(Date date) { // TODO Auto-generated method stub // find the corresponding list<Task> in the hashmap // give this list to the listview Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, date.getYear() + 1900); c.set(Calendar.MONTH, date.getMonth()); c.set(Calendar.DAY_OF_MONTH, date.getDate()); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0);// w ww . j av a2 s . co m c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); List<Task> l = TaskMap.get(c); if (l == null) { tv_calendar_notaskfordate.setVisibility(View.VISIBLE); List<Task> i = new ArrayList<Task>(); info_adapter = new InfoListAdapter(context, R.layout.calendar_info_single_row, i); info_list.setAdapter(info_adapter); info_list.setVisibility(View.GONE); return false; } else { if (!l.isEmpty()) { info_list.setVisibility(View.VISIBLE); tv_calendar_notaskfordate.setVisibility(View.GONE); info_adapter = new InfoListAdapter(context, R.layout.calendar_info_single_row, l); info_list.setAdapter(info_adapter); info_list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub Intent intent = new Intent(context, EditTask.class); Bundle b = new Bundle(); b.putInt("id", info_adapter.getId(position)); intent.putExtra("info", b); context.startActivity(intent); } }); return true; } else { info_list.setVisibility(View.GONE); tv_calendar_notaskfordate.setVisibility(View.VISIBLE); return false; } } }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorTest.java
public void testGoodTransform() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); ModelInfo info = createModel();//w w w.ja va 2 s. co m CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); gen.preview(session); DataRow rows[] = info.getData(); assertNotNull(rows); assertEquals(235, rows.length); Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); // test the first row // test the data types DataRow row = rows[0]; assertNotNull(row); Object cells[] = row.getCells(); assertNotNull(cells); // assertEquals( 8, cells.length ); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] instanceof String); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 3, cells[0]); assertEquals(25677.96525, cells[1]); assertEquals((long) 1231, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", cells[4]); assertEquals((long) 11, cells[5]); assertEquals(111.9090909, cells[6]); assertEquals(false, cells[7]); // test the second row testDate.setDate(2); // test the data types row = rows[1]; assertNotNull(row); cells = row.getCells(); assertNotNull(cells); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] == null); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 4, cells[0]); assertEquals(24261.81026, cells[1]); assertEquals((long) 1663, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals(null, cells[4]); // IfNull value does not seem to work assertEquals((long) 7, cells[5]); assertEquals(237.5714286, cells[6]); assertEquals(true, cells[7]); }
From source file:pidev.tunipharma.gui.InterfaceAdmin.java
/** * @param t type de pharmacie/*from www .j a v a2s . c o m*/ * @param g id gouvernorat * @param v id ville * @param n nom pharmacie */ private void fillTableModPha(int t, int g, int v, String n) { List<Pharmacie> l = PharmaciesDAO.getInstance().readByTypeVilleGouvTypeNom(t, g, v, n); GUIUtil.rempTablePha(tableModPha, l); Date d = new Date(); StatistiquesDAO.getInstance() .create(new Statistiques(-1, Statistiques.STAT_RECHERCHE, 0, d.getMonth(), -1, d.getYear() + 1900)); StatistiquesDAO.getInstance().updateByMoisAnneType(d.getMonth(), d.getYear() + 1900, Statistiques.STAT_RECHERCHE); }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorIT.java
public void testGoodTransform() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL = System.getProperty("KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL", "N"); ModelInfo info = createModel();/* w w w. j av a 2s . c om*/ CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); gen.preview(session); DataRow rows[] = info.getData(); assertNotNull(rows); assertEquals(235, rows.length); Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); // test the first row // test the data types DataRow row = rows[0]; assertNotNull(row); Object cells[] = row.getCells(); assertNotNull(cells); // assertEquals( 8, cells.length ); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] instanceof String); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 3, cells[0]); assertEquals(25677.96525, cells[1]); assertEquals((long) 1231, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", cells[4]); assertEquals((long) 11, cells[5]); assertEquals(111.9090909, cells[6]); assertEquals(false, cells[7]); // test the second row testDate.setDate(2); // test the data types row = rows[1]; assertNotNull(row); cells = row.getCells(); assertNotNull(cells); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); if ("Y".equals(KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL)) { assertTrue("".equals(cells[4])); } else { assertTrue(cells[4] == null); } assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 4, cells[0]); assertEquals(24261.81026, cells[1]); assertEquals((long) 1663, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); if ("Y".equals(KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL)) { assertEquals("", cells[4]); assertEquals(cells[4], ""); } else { assertEquals(null, cells[4]); // IfNull value does not seem to work } assertEquals((long) 7, cells[5]); assertEquals(237.5714286, cells[6]); assertEquals(true, cells[7]); }
From source file:com.owncloud.android.ui.fragment.contactsbackup.ContactsBackupFragment.java
public void openDate(@Nullable Date savedDate) { final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity(); String backupFolderString = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;/*from w w w. j a v a2 s . c om*/ OCFile backupFolder = contactsPreferenceActivity.getStorageManager().getFileByPath(backupFolderString); Vector<OCFile> backupFiles = contactsPreferenceActivity.getStorageManager().getFolderContent(backupFolder, false); Collections.sort(backupFiles, new Comparator<OCFile>() { @Override public int compare(OCFile o1, OCFile o2) { if (o1.getModificationTimestamp() == o2.getModificationTimestamp()) { return 0; } if (o1.getModificationTimestamp() > o2.getModificationTimestamp()) { return 1; } else { return -1; } } }); Calendar cal = Calendar.getInstance(); int year; int month; int day; if (savedDate == null) { year = cal.get(Calendar.YEAR); month = cal.get(Calendar.MONTH) + 1; day = cal.get(Calendar.DAY_OF_MONTH); } else { year = savedDate.getYear(); month = savedDate.getMonth(); day = savedDate.getDay(); } if (backupFiles.size() > 0 && backupFiles.lastElement() != null) { datePickerDialog = new DatePickerDialog(contactsPreferenceActivity, this, year, month, day); datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp()); datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp()); datePickerDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectedDate = null; } }); datePickerDialog.show(); } else { Toast.makeText(contactsPreferenceActivity, R.string.contacts_preferences_something_strange_happened, Toast.LENGTH_SHORT).show(); } }
From source file:com.cssweb.android.view.TrendView.java
private void repairData() throws JSONException { close = quoteData.getDouble("close"); high = quoteData.getDouble("high"); low = quoteData.getDouble("low"); jrkp = quoteData.getDouble("jrkp"); Date dt = new Date(); int year = dt.getYear(); int month = dt.getMonth(); int day = dt.getDate(); int hour = dt.getHours(); int minute = dt.getMinutes(); JSONArray list = quoteData.getJSONArray("data"); if (quoteData.getString("quotetime") != null && !quoteData.getString("quotetime").equals("")) { year = Integer.parseInt(quoteData.getString("quotetime").substring(0, 4)); month = Integer.parseInt(quoteData.getString("quotetime").substring(5, 7)) - 1; day = Integer.parseInt(quoteData.getString("quotetime").substring(8, 10)); hour = Integer.parseInt(quoteData.getString("quotetime").substring(11, 13)); minute = Integer.parseInt(quoteData.getString("quotetime").substring(14, 16)); dt = new Date(year, month, day, hour, minute); }// w w w. ja va 2 s.c om JSONArray jsonArray = new JSONArray(); if ("hk".equals(exchange)) { this.MINUTES = 300; Date dt1 = new Date(year, month, day, 9, 30); Date dt2 = new Date(year, month, day, 12, 0); Date dt3 = new Date(year, month, day, 13, 31); Date dt4 = new Date(year, month, day, 16, 0); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 151; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 151 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime()) { hopelen = 301; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null" || quoteData.getString("quotetime").equals("")) { hopelen = 1; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 151) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 151 && i <= 301) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 151))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("close")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } else if ("cf".equals(exchange)) { this.MINUTES = 270; Date dt1 = new Date(year, month, day, 9, 15); Date dt2 = new Date(year, month, day, 11, 30); Date dt3 = new Date(year, month, day, 13, 1); Date dt4 = new Date(year, month, day, 15, 15); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 136; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 136 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime()) { hopelen = 271; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null") { hopelen = 0; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 136) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 136 && i <= 271) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 136))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("jrkp")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } else if ("dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) { this.MINUTES = 225; Date dt1 = new Date(year, month, day, 9, 0); Date dt2 = new Date(year, month, day, 10, 15); Date dt3 = new Date(year, month, day, 10, 31); Date dt4 = new Date(year, month, day, 11, 30); Date dt5 = new Date(year, month, day, 13, 31); Date dt6 = new Date(year, month, day, 15, 0); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 76; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 76 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime() && dt.getTime() < dt5.getTime()) { hopelen = 136; } if (dt.getTime() >= dt5.getTime() && dt.getTime() < dt6.getTime()) { hopelen = 136 + (dt.getTime() - dt5.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt6.getTime()) { hopelen = 226; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null") { hopelen = 0; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 76) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 76 && i < 136) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 76))); } if (i >= 136 && i <= 226) { time = Utils.format(new Date(dt5.getTime() + 1000 * 60 * (i - 136))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("jrkp")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } else { Date dt1 = new Date(year, month, day, 9, 30); Date dt2 = new Date(year, month, day, 11, 30); Date dt3 = new Date(year, month, day, 13, 1); Date dt4 = new Date(year, month, day, 15, 0); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 121; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 121 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime()) { hopelen = 241; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null") { hopelen = 0; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 121) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 121 && i <= 241) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 121))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("close")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } //Log.i("#########getSecurityType##########", NameRule.getSecurityType(exchange, stockcode)+">>>>>>>>>>>>>>"); // if(NameRule.getSecurityType(exchange, stockcode)==15 // || NameRule.getSecurityType(exchange, stockcode)==5 // || NameRule.getSecurityType(exchange, stockcode)==35){ // quoteArray = null; // return; // }else{ // quoteArray = jsonArray; // } quoteArray = jsonArray; actualDataLen = quoteArray.length(); if (!isTrackStatus) isTrackNumber = actualDataLen - 1;//?? highvolume = TickUtil.gethighVolume(quoteArray); highamount = TickUtil.gethighAmount(quoteArray); high = Math.max(TickUtil.gethighPrice(quoteArray, quoteArray.length()), close); low = Math.min(TickUtil.getlowPrice(quoteArray, quoteArray.length()), close); if ("sz399001".equals(exchange + stockcode) || "sh000001".equals(exchange + stockcode)) { //?????? int len = quoteData.getJSONArray("data2").length() - 1; high = Math.max(high, TickUtil.gethighPrice(quoteData.getJSONArray("data2"), len)); low = Math.min(low, TickUtil.getlowPrice(quoteData.getJSONArray("data2"), len)); } }
From source file:forseti.JUtil.java
@SuppressWarnings("deprecation") public static synchronized int obtMes(Date fech) { return fech.getMonth(); }