コード例 #1
0
  public void setLaufzeit(DataPointVector DPVector, int vorlaufzeit_jahre, int laufzeit) {
    Date Beginn = new Date();
    Date Ende = new Date();
    int laufzeit_jahre = RandomNumber(2, 25);
    Date Stichtag = Calendar.getInstance().getTime();

    DPVector.addDataPoint("AI_Stichtag_Datum", Stichtag);

    Beginn.setYear((2014 - vorlaufzeit_jahre) - 1900);
    Beginn.setMonth(RandomNumber(1, 12));
    Beginn.setDate(RandomNumber(1, 28));

    Ende.setYear(2014 + laufzeit_jahre - 1900);
    Ende.setMonth(RandomNumber(1, 12));
    Ende.setDate(RandomNumber(1, 28));

    // Ende Laufzeit
    //
    DPVector.addDataPoint("GF17_Vertragsbeginn_Datum", Beginn);
    DPVector.addDataPoint("GF18_Kapitalbeginn_Datum", Beginn);
    DPVector.addDataPoint("GF19_Kapitalende_Datum", Ende);

    DPVector.addDataPoint("GF52_Vertragsende_Datum", Ende);
    DPVector.addDataPoint(
        "GFA83_Ursprungslaufzeit_Code", BCAlgos.XEN_Laufzeitenberechnung(Beginn, Ende));
    DPVector.addDataPoint(
        "GFA84_Restlaufzeit_Code", BCAlgos.XEN_Laufzeitenberechnung(Stichtag, Ende));
  }
コード例 #2
0
 public void adjustDate(Date d) {
   if (DateIntervalType.MILLENIUM.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 1000);
   }
   if (DateIntervalType.CENTURY.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 100);
   }
   if (DateIntervalType.DECADE.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 10);
   }
   if (DateIntervalType.YEAR.equals(type)) {
     d.setYear(d.getYear() + (int) quantity);
   }
   if (DateIntervalType.QUARTER.equals(type)) {
     d.setMonth(d.getMonth() + (int) quantity * 3);
   }
   if (DateIntervalType.MONTH.equals(type)) {
     d.setMonth(d.getMonth() + (int) quantity);
   }
   if (DateIntervalType.WEEK.equals(type)) {
     d.setDate(d.getDate() + (int) quantity * 7);
   }
   if (DateIntervalType.DAY.equals(type)) {
     d.setDate(d.getDate() + (int) quantity);
   }
   if (DateIntervalType.HOUR.equals(type)) {
     d.setHours(d.getHours() + (int) quantity);
   }
   if (DateIntervalType.MINUTE.equals(type)) {
     d.setMinutes(d.getMinutes() + (int) quantity);
   }
   if (DateIntervalType.SECOND.equals(type)) {
     d.setSeconds(d.getSeconds() + (int) quantity);
   }
 }
コード例 #3
0
  public Date transformarJulianaAGregoriadeLong(Long valor) {
    String j = valor.toString();
    Date date = new Date();
    String primerValor = "";
    if (j.length() == 5) {
      try {
        date = new SimpleDateFormat("yyD").parse(j);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      primerValor = j.substring(0, 1);
      if (primerValor.equals("1")) {
        String anno = j.substring(1, 3);
        date.setYear(Integer.valueOf("20" + anno) - 1900);
        String s = j.substring(3);
        Date fecha = new Date();
        try {
          fecha = new SimpleDateFormat("D").parse(s);
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        fecha.setYear(date.getYear());
        return fecha;
      }
    }

    return date;
  }
コード例 #4
0
 @SuppressWarnings("deprecation")
 public static Date getNextDate(Date fecha) {
   Date nextFecha = createDate();
   int year = fecha.getYear();
   int month = fecha.getMonth();
   if (month == 11) {
     nextFecha.setYear(year + 1);
     nextFecha.setMonth(0);
   } else {
     nextFecha.setYear(year);
     nextFecha.setMonth(month + 1);
   }
   return nextFecha;
 }
コード例 #5
0
  // PRUEBA COD CALENDARIO
  public static Cod_calendario main(String args[]) {
    Object[][] tuplas = null;
    int col = 6, fil = 10; // valores iniciales

    Calendar calendario = Calendar.getInstance();

    Date fecha = calendario.getTime();
    Date fecha2 = new Date();
    Date fecha3 = new Date();
    Date fecha4 = new Date();
    fecha2.setDate(5);
    fecha3.setMonth(5);
    fecha4.setYear(116);

    // fecha.setDate(0); fecha.setHours(0); fecha.setMinutes(0); fecha.setMonth(0);
    // fecha.setSeconds(0); fecha.setYear(0);

    tuplas = new Object[fil][col];

    // System.out.println("Fecha 1 "+fecha+" Fecha 2 "+fecha2+" Fecha 3 "+fecha3+" Fecha 4
    // "+fecha4);
    tuplas = llenar_prueba(fil, col, tuplas, fecha, fecha2, fecha3, fecha4);

    Cod_calendario calen = new Cod_calendario(fil, col, tuplas);

    System.out.println();
    System.out.println();

    calen.procesar_cita(fecha4);

    return calen;
  }
コード例 #6
0
ファイル: FacebookUser.java プロジェクト: life02/newsfeed
    public void setBirthday(String birthday) {
      this.birthday = birthday;
      if (this.birthday != null && !this.birthday.equals("")) {
        String tempstr = this.birthday;
        int year = new Date().getYear() + 1900;

        if (tempstr.indexOf(",") == -1) {
          tempstr = tempstr + "," + year;
        } else {
          tempstr = tempstr.substring(0, tempstr.indexOf(",")) + "," + year;
        }

        SimpleDateFormat df = new SimpleDateFormat("MMMM dd,yyyy", Locale.US);
        try {
          Date tempDate = df.parse(tempstr);
          b_month = tempDate.getMonth();
          b_date = tempDate.getDate();
          this.bd_date = tempDate.getTime();
          long distance = System.currentTimeMillis() - bd_date;
          if (distance >= 7 * 24 * 60 * 60 * 1000L) {
            Date dd = new Date(bd_date);
            dd.setYear(dd.getYear() + 1 + 1900);
            bd_date = dd.getTime();
          }
        } catch (ParseException e) {
          this.bd_date = 0;
        }
      }
    }
コード例 #7
0
  /**
   * 根据字符串传成date
   *
   * @param String
   * @return Date
   */
  public static Date strToDate(String s) {

    Date mydate = new Date();

    if (s.length() == 10) {
      mydate.setYear(Integer.parseInt(s.substring(0, 4)));
      mydate.setMonth(Integer.parseInt(s.substring(5, 7)));
      mydate.setDate(Integer.parseInt(s.substring(8, 10)));
    }
    if (s.length() == 8) {
      mydate.setYear(Integer.parseInt(s.substring(0, 4)));
      mydate.setMonth(Integer.parseInt(s.substring(4, 6)));
      mydate.setDate(Integer.parseInt(s.substring(6, 8)));
    }
    return mydate;
  }
コード例 #8
0
  @SuppressWarnings({"deprecation"})
  public void testUserAgentNeedsUpdate1() throws Exception {

    ResourceHandler handler = getFacesContext().getApplication().getResourceHandler();
    assertTrue(handler != null);

    // no If-Modified-Since request header, so this should always
    // return true
    Resource resource = handler.createResource("duke-nv.gif");
    assertTrue(resource.userAgentNeedsUpdate(getFacesContext()));

    // set the creation date of the ResourceHandler back in time so that
    // if the header was present it would return true - the lack of the header
    // should result in true being returned in this case
    Date date = new Date();
    date.setYear(1980);
    long origTime =
        (Long)
            TestingUtil.invokePrivateMethod(
                "getCreationTime", null, null, ResourceHandlerImpl.class, handler);
    TestingUtil.invokePrivateMethod(
        "setCreationTime",
        new Class[] {Long.TYPE},
        new Object[] {date.getTime()},
        ResourceHandlerImpl.class,
        handler);
    assertTrue(resource.userAgentNeedsUpdate(getFacesContext()));
    TestingUtil.invokePrivateMethod(
        "setCreationTime",
        new Class[] {Long.TYPE},
        new Object[] {origTime},
        ResourceHandlerImpl.class,
        handler);
  }
コード例 #9
0
  public static void showUpcomingBirthdays(Long id) {
    User current = User.findById(id);

    Date today = new Date();
    int day = today.getDate();
    Date weekLater = new Date();
    weekLater.setDate(day + 7);

    Date almostWeekLater = new Date();
    almostWeekLater.setDate(day + 6);

    List<Relationship> friends = current.confirmedFriends();
    List<User> birthdayPeople = new ArrayList<User>();

    for (Relationship x : friends) {
      Date friendBirthday = x.to.getProfile().birthday;

      if (friendBirthday == null) // The user's friend did not set a birthday date field
      {
        // x.to.getProfile().birthday = almostWeekLater;
        // friendBirthday =  almostWeekLater;
        continue;
      }

      friendBirthday.setYear(today.getYear());
      if (friendBirthday.before(weekLater)) birthdayPeople.add(x.to);
    }

    render(birthdayPeople, today, weekLater, almostWeekLater, day);
  }
コード例 #10
0
    private int compare(Date d1, Date d2) {

      Date left = (Date) d1.clone();
      left.setYear(2010);
      left.setMonth(1);
      left.setDate(0);

      Date right = (Date) d2.clone();
      right.setYear(2010);
      right.setMonth(1);
      right.setDate(0);

      int returnValue = left.compareTo(right);

      return returnValue;
    }
コード例 #11
0
 public static void main(String[] args) {
   Date date = new Date();
   date.setDate(14);
   date.setMonth(01);
   date.setYear(85);
   SimpleDateFormat sdt = new SimpleDateFormat("dd MMM YYYY", Locale.ENGLISH);
   System.out.println(sdt.format(date));
 }
コード例 #12
0
 public void onClick(View arg0) {
   _init.setYear(_datePicker.getYear() - 1900);
   _init.setMonth(_datePicker.getMonth());
   _init.setDate(_datePicker.getDayOfMonth());
   _init.setHours(_timePicker.getCurrentHour());
   _init.setMinutes(_timePicker.getCurrentMinute());
   sendResult(_callback, _init, _opaque);
 }
コード例 #13
0
ファイル: CalendarWidget.java プロジェクト: osarrat/sigmah
 @Override
 public void firstDay(Date currentDate, Date today, int firstDay) {
   int decal = (today.getDay() + 7 - firstDay) % 7;
   currentDate.setYear(today.getYear());
   currentDate.setMonth(today.getMonth());
   currentDate.setDate(today.getDate() - decal);
   final Date date = getFirstDateOfWeek(today, firstDay);
   currentDate.setTime(date.getTime());
 }
コード例 #14
0
 @RequestMapping(value = "editproject", method = RequestMethod.GET)
 protected ModelAndView edit(Integer id) throws Exception {
   ModelAndView mav = new ModelAndView();
   List<ProjectType> projectTypes = projectDao.getProjectTypes();
   Map<Integer, String> pTypes = new LinkedHashMap<Integer, String>();
   if (projectTypes != null) {
     for (ProjectType pt : projectTypes) {
       pTypes.put(pt.getId(), pt.getName());
     }
   }
   List<ProjectStatus> st = projectDao.getProjectStatuses();
   Map<Integer, String> statuses = new LinkedHashMap<Integer, String>();
   if (st != null) {
     for (ProjectStatus s : st) {
       statuses.put(s.getId(), s.getName());
     }
   }
   ProjectWrapper pw = null;
   if (id == null) {
     pw = new ProjectWrapper();
     DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
     Date startDate = new Date();
     Date nextReview = new Date();
     Date nextFollowUp = new Date();
     nextReview.setYear(nextReview.getYear() + 1);
     nextFollowUp.setMonth(nextFollowUp.getMonth() + 3);
     pw.getProject().setStartDate(df.format(startDate));
     pw.getProject().setNextFollowUpDate(df.format(nextFollowUp));
     pw.getProject().setNextReviewDate(df.format(nextReview));
     this.tempProjectManager.register(pw);
   } else {
     if (id < 0) {
       if (this.tempProjectManager.isRegistered(id)) {
         pw = tempProjectManager.get(id);
       } else {
         pw = new ProjectWrapper();
         pw.getProject().setId(id);
         this.tempProjectManager.register(id, pw);
       }
     } else {
       this.authzAspect.verifyUserIsAdviserOnProject(id);
       if (this.tempProjectManager.isRegistered(id)) {
         pw = tempProjectManager.get(id);
       } else {
         pw = this.projectDao.getProjectWrapperById(id);
       }
       this.tempProjectManager.register(id, pw);
     }
   }
   pw.setSecondsLeft(this.tempProjectManager.getSessionDuration());
   mav.addObject("projectWrapper", pw);
   mav.addObject("projectTypes", pTypes);
   mav.addObject("statuses", statuses);
   mav.addObject("institutions", this.projectDao.getInstitutions());
   return mav;
 }
コード例 #15
0
  /**
   * 根据生日获取年龄
   *
   * @param birthday
   * @return
   */
  public static int getAge(Date birthday) {
    if (birthday == null) {
      return 0;
    }
    if (birthday.getYear() > getDateDetail(System.currentTimeMillis())[0]) {
      birthday.setYear(birthday.getYear() - TimeUtil.SYSTEM_START_DATE[0]);
    }

    return getAge(new int[] {birthday.getYear(), birthday.getMonth(), birthday.getDay()});
  }
コード例 #16
0
  // ----------------------------------------------------
  // POSITIVE TEST CASES
  // ----------------------------------------------------
  // - A user who is not authenticated must be able to:
  //	o Place an order to send a flower to a recipient.
  @Test
  public void testPlaceFlowerOrder() {
    FlowerOrder flowerOrder = flowerOrderService.create(10);
    flowerOrder.setAddress("aADSDADASDasdasd");

    CreditCard creditCard = new CreditCard();
    creditCard.setBrandName("adasdasdad");
    creditCard.setCvvCode(122);
    creditCard.setExpirationMonth(1);
    creditCard.setExpirationYear(2020);
    creditCard.setHolderName("asdasdsad");
    creditCard.setNumber("4929468422750785");

    Customer recipient = new Customer();
    recipient.setEmailAddress("*****@*****.**");
    recipient.setName("adsadasdasdd");
    recipient.setSurname("asdasdasdasawq");
    recipient.setPhoneNumber("+34sadsad dadsad");
    Date birthdate = new Date();
    birthdate.setDate(4);
    birthdate.setMonth(4);
    birthdate.setYear(90);
    recipient.setBirthdate(birthdate);

    Customer sender = new Customer();
    sender.setEmailAddress("*****@*****.**");
    sender.setName("adsadasdasdd");
    sender.setSurname("asdasdasdasawq");
    sender.setPhoneNumber("+34sadsad dadsad");
    Date birthdate2 = new Date();
    birthdate2.setDate(4);
    birthdate2.setMonth(4);
    birthdate2.setYear(90);
    sender.setBirthdate(birthdate2);

    flowerOrder.setRecipient(recipient);
    flowerOrder.setSender(sender);
    flowerOrder.setCreditCard(creditCard);

    flowerOrderService.save(flowerOrder);
  }
コード例 #17
0
  /**
   * Gets a date from a string created in saveDateToString
   *
   * @param data
   */
  public void readDateFromString(String data) {
    // System.out.println(data);
    String deliminator = "[+]+";
    String[] tokens = data.split(deliminator);

    dateAdded.setDate(Integer.decode(tokens[0]));
    dateAdded.setHours(Integer.decode(tokens[1]));
    dateAdded.setMinutes(Integer.decode(tokens[2]));
    dateAdded.setMonth(Integer.decode(tokens[3]));
    dateAdded.setSeconds(Integer.decode(tokens[4]));
    dateAdded.setYear(Integer.decode(tokens[5]));
  }
コード例 #18
0
  public void testCopyDate() {
    Date original = new Date(99, 5, 15, 3, 30, 5);

    // Copy the date
    Date copy = CalendarUtil.copyDate(original);
    assertEquals(original, copy);
    assertEquals(99, original.getYear());

    // Mutate the copy
    copy.setYear(70);
    assertEquals(99, original.getYear());
    assertEquals(70, copy.getYear());
  }
コード例 #19
0
  /**
   * @param birthday
   * @return
   */
  public static String getSmartBirthday(Date birthday) {
    if (birthday == null) {
      return "";
    }
    if (birthday.getYear() > getDateDetail(System.currentTimeMillis())[0]) {
      birthday.setYear(birthday.getYear() - TimeUtil.SYSTEM_START_DATE[0]);
    }

    return getSmartBirthday(birthday.getTime(), false)
        + " "
        + (TimeUtil.getDateDetail(System.currentTimeMillis())[0] - birthday.getYear())
        + "岁";
  }
コード例 #20
0
  @Override
  public Date toDate(String arg0) {
    if (arg0 == null) return null;

    String[] str = arg0.split("-");

    Date d = new Date();
    d.setDate(this.toInteger(str[0]));
    d.setMonth(this.toInteger(str[1]));
    d.setYear(this.toInteger(str[2]));

    return d;
  }
コード例 #21
0
  /** Update Date values */
  private void updateDate() {
    int dateStamp = rmcSentence.getDate();

    if (dateStamp > 0) {
      String rd = Integer.toString(dateStamp);
      int dd = Integer.parseInt(rd.substring(0, rd.length() - 4));
      int mm = Integer.parseInt(rd.substring(rd.length() - 4, rd.length() - 2));
      int yy = Integer.parseInt(rd.substring(rd.length() - 2, rd.length()));

      date.setDay(dd);
      date.setMonth(mm);
      date.setYear(yy);
    }
  }
コード例 #22
0
  private void filterButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_filterButtonActionPerformed
    m = monthComboBox.getSelectedIndex();
    String yearString = yearField.getText();
    if (yearString.equals("")) {
      JOptionPane.showMessageDialog(null, "Введите год", "Ошибка", JOptionPane.ERROR_MESSAGE);
      return;
    }
    int year = Integer.valueOf(yearString);
    infoLabel.setText(
        "Отображаются записи за "
            + monthComboBox.getSelectedItem().toString()
            + " "
            + yearString
            + " года.");
    infoLabel.setVisible(true);
    Date beginDate = new Date();
    Date endDate = new Date();
    beginDate.setYear(year - 1900);
    beginDate.setMonth(m);
    beginDate.setDate(0);
    endDate.setYear(year - 1900);
    endDate.setMonth(m);
    endDate.setDate(SaldoCalculator.daysQuantity(m, year));

    List<RowFilter<Object, Object>> filters = new ArrayList<>(2);
    filters.add(RowFilter.dateFilter(ComparisonType.AFTER, beginDate));
    filters.add(RowFilter.dateFilter(ComparisonType.BEFORE, endDate));

    TableRowSorter moneySorter = new TableRowSorter(moneyTable.getModel());
    moneySorter.setRowFilter(RowFilter.andFilter(filters));
    moneyTable.setRowSorter(moneySorter);

    TableRowSorter productSorter = new TableRowSorter(productTable.getModel());
    productSorter.setRowFilter(RowFilter.andFilter(filters));
    productTable.setRowSorter(productSorter);
  } // GEN-LAST:event_filterButtonActionPerformed
コード例 #23
0
  public static void main(String[] args) {
    // Attack the internals of a Period instance - Page 185
    Date start = new Date();
    Date end = new Date();
    Period p = new Period(start, end);
    end.setYear(78); // Modifies internals of p!
    System.out.println(p);

    // Second attack on the internals of a Period instance - Page 186
    start = new Date();
    end = new Date();
    p = new Period(start, end);
    p.end().setYear(78); // Modifies internals of p!
    System.out.println(p);
  }
コード例 #24
0
  /**
   * Método encargado de crear el reporte anual de gastos
   *
   * @param fechaInicio Fecha inicio del reporte
   * @param fechaFinal Fecha final del reporte
   * @param nombreArchivo Nombre del archivo con que se nombrará el reporte
   */
  public void reporteGastos(Date fechaInicio, Date fechaFinal, String nombreArchivo) {

    if (fechaFinal == null) {
      fechaFinal = new Date(fechaInicio.getTime());
      fechaInicio.setYear(fechaInicio.getYear() - 1);
    }

    Map parametros = new HashMap();

    parametros.put("inicio", fechaInicio);
    parametros.put("final", fechaFinal);

    conectar();

    guardarPDF(archivoGastos, parametros, nombreArchivo);

    cerrarConexion();
  }
コード例 #25
0
  @SuppressWarnings("deprecation")
  public void constructor() {

    Date statDate = new Date();
    statDate.setYear(2009);
    statDate.setMonth(0);
    statDate.setDate(2);

    String statType = "Folate";

    String[] readings = {
      "11.1", "14.5", "17.9", "8.7", "15.7", "12.3", "2.8", "14.9", "4.5", "7.8", "6.6", "10.6",
      "23.0", "19.0", "4.7", "9.5", "7.1", "13.5", "9.5", "3.5", "16.1", "21.7", "11.2", "9.8",
      "13.8", "20.7", "6.6", "4.2", "6.2", "19.9", "15.9", "21.8", "9.0"
    };

    AnalyteDate day = new AnalyteDate(statType, statDate, Arrays.asList(readings));

    // Maybe this should take in an array of number and just have getters
    AnalyteStat folate02Jan2009 = ComputeAnalyteStats.computeDay(day, statType);

    double min = 2.8;
    double i2p5th = 3.36;
    double i25th = 7.1;
    double median = 11.1;
    double mean = 11.942;
    String[] mode = new String[] {"6.6", "9.5"};
    double i75th = 15.9;
    double i97p5th = 22.04;
    double max = 23.0;

    assertEquals(statDate, folate02Jan2009.getIncludedDates().get(0));
    assertEquals(statType, folate02Jan2009.getAnalyteType());

    assertEquals(min, folate02Jan2009.getMin(), 0.001);
    //		assertEquals(i2p5th, folate02Jan2009.getPercentile(0.025), 0.001);
    //		assertEquals(i25th, folate02Jan2009.getPercentile(0.25), 0.001);
    //		assertEquals(median, folate02Jan2009.getPercentile(0.5), 0.001);
    assertEquals(mean, folate02Jan2009.getMean(), 0.001);
    // assertTrue(Arrays.asList(mode).contains(folate02Jan2009.getMode()[0]));
    //		assertEquals(i75th, folate02Jan2009.getPercentile(0.75), 0.001);
    //		assertEquals(i97p5th, folate02Jan2009.getPercentile(0.975), 0.001);
    assertEquals(max, folate02Jan2009.getMax(), 0.001);
  }
  @SuppressWarnings("deprecation")
  public static String readBook() throws InputMismatchException {

    IOUtil.print("Name:");
    String name = IOUtil.readString();
    IOUtil.print("Author:");
    String author = IOUtil.readString();
    IOUtil.print("Price:");
    double price = IOUtil.readDouble();
    IOUtil.print("Number Of Exemplars:");
    Integer numberOfExemplars = IOUtil.readInt();
    IOUtil.print("Date Of Arrival:");
    Date dop = SpecificIOFeaturesUtil.readDate();
    Date doa = new Date();
    doa.setMonth(doa.getMonth() + 1);
    doa.setYear(doa.getYear() + 1900);
    StringBuilder sb = new StringBuilder();
    sb.append(readId());
    sb.append(";");
    sb.append(name);
    sb.append(";");
    sb.append(author);
    sb.append(";");
    sb.append(numberOfExemplars);
    sb.append(";");
    sb.append(Double.toString(price));
    sb.append(";");
    sb.append(Integer.toString(doa.getYear()));
    sb.append(";");
    sb.append(Integer.toString(doa.getMonth()));
    sb.append(";");
    sb.append(Integer.toString(doa.getDate()));
    sb.append(";");
    sb.append(Integer.toString(dop.getYear()));
    sb.append(";");
    sb.append(Integer.toString(dop.getMonth()));
    sb.append(";");
    sb.append(Integer.toString(dop.getDate()));

    return sb.toString();
  }
コード例 #27
0
  public static void date_deserialize(Date date, String dat) {

    //		String [] str = dat.split("-");
    //		date.setDate(Integer.parseInt(str[0]));
    //		date.setTime(Integer.parseInt(str[1]));
    String[] str = dat.split(" ");
    String[] da = str[0].split("-");
    String[] ta = str[1].split(":");
    date.setYear(Integer.parseInt(da[0]));
    date.setMonth(Integer.parseInt(da[1]));
    date.setDate(Integer.parseInt(da[2]));
    date.setHours(Integer.parseInt(ta[0]));
    date.setMinutes(Integer.parseInt(ta[1]));
    date.setSeconds(Integer.parseInt(ta[2]));
    //
    // date.s
    // date.set
    // str+=String.valueOf(date.getYear())+"-"+String.valueOf(date.getMonth())+"-"+String.valueOf(date.getDay())+" ";
    // str+=String.valueOf(date.getHours())+":"+String.valueOf(date.getMinutes())+":"+String.valueOf(date.getSeconds());
    // return str;
  }
コード例 #28
0
 public final Date getDate(String key) {
   String type = getType(key);
   if ("number".equals(type)) {
     return new Date(getLong(key));
   } else if ("date".equals(type)) {
     return getNativeDate(key);
   } else if ("string".equals(type)) {
     // DateTimeFormat dtf = DateTimeFormat.getFormat(Defaults.getDateFormat());
     // return dtf.parse(get(key));
   } else if ("array".equals(type)) {
     JsArrayInteger jsAray = getNativeValue(key).cast();
     Date date = new Date();
     date.setYear(jsAray.get(0));
     date.setMonth(jsAray.get(1));
     date.setDate(jsAray.get(2));
     if (jsAray.length() > 3) {
       date.setHours(jsAray.get(3));
       date.setMinutes(jsAray.get(4));
       date.setSeconds(jsAray.get(5));
     }
     return date;
   }
   return null;
 }
コード例 #29
0
ファイル: DateTest.java プロジェクト: djbone/j2objc
 /** @tests java.util.Date#setYear(int) */
 public void test_setYearI() {
   // Test for method void java.util.Date.setYear(int)
   Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9).getTime();
   d.setYear(8);
   assertEquals("Set incorrect year", 8, d.getYear());
 }
コード例 #30
0
  public static String formatDateTime(Context ctx, String date) {
    /*
     * Date as: Tue Sep 03 19:12:43 +0800 2013
     */
    String[] times = date.split(" ");

    Loge.i("Origin Data : " + date);
    Loge.i("times.length : " + times.length);

    StringBuffer sbDate = new StringBuffer("");

    if (times.length < 6) {
      return null;
    }

    Date finalDate = new Date();

    Month mKey = Month.valueOf(times[1]);

    switch (mKey) {
      case Jan:
        finalDate.setMonth(1);
        break;
      case Feb:
        finalDate.setMonth(2);
        break;
      case Apr:
        finalDate.setMonth(3);
        break;
      case May:
        finalDate.setMonth(4);
        break;
      case Mar:
        finalDate.setMonth(5);
        break;
      case Jun:
        finalDate.setMonth(6);
        break;
      case Jul:
        finalDate.setMonth(7);
        break;
      case Aug:
        finalDate.setMonth(8);
        break;
      case Sep:
        finalDate.setMonth(9);
        break;
      case Oct:
        finalDate.setMonth(10);
        break;
      case Nov:
        finalDate.setMonth(11);
        break;
      case Dec:
        finalDate.setMonth(12);
        break;
      default:
        break;
    }

    String day = times[2];
    Loge.i("Data day : " + day);
    if (day.startsWith("0")) {
      day = day.substring(1);
    }

    finalDate.setDate(Integer.parseInt(day));

    String[] dayTimes = times[3].split(":");

    for (int i = 0; i < dayTimes.length; i++) {
      switch (i) {
        case 0:
          finalDate.setHours(Integer.parseInt(dayTimes[0]));
          break;
        case 1:
          finalDate.setMinutes(Integer.parseInt(dayTimes[1]));
          break;
        case 2:
          finalDate.setSeconds(Integer.parseInt(dayTimes[2]));
          break;
        default:
          break;
      }
    }

    finalDate.setYear(Integer.valueOf(times[5]));

    sbDate.append(finalDate.getMonth());
    sbDate.append(ctx.getResources().getString(R.string.month));
    sbDate.append(finalDate.getDate());
    sbDate.append(ctx.getResources().getString(R.string.day));
    sbDate.append(" ");
    sbDate.append(finalDate.getHours());
    sbDate.append(":");
    if (finalDate.getMinutes() == 0) {
      sbDate.append("00");
    } else {
      sbDate.append(finalDate.getMinutes());
    }

    finalDate = null;

    Loge.i("Data String : " + sbDate.toString());

    return sbDate.toString();
  }