Package java.text

Examples of java.text.Format.parseObject()


    public void test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall() throws Exception {
        // SimpleDateFormat throws StringIndexOutOfBoundException
        DateTimeFormatter dtf = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
        ParsePosition pos = new ParsePosition(-1);
        Format test = dtf.toFormat();
        assertNull(test.parseObject("ONE30", pos));
        assertTrue(pos.getErrorIndex() >= 0);
    }

    //-----------------------------------------------------------------------
    @Test
View Full Code Here


    }

    @Test
    public void test_toFormat_Class_parseObject_String() throws Exception {
        Format format = DATE_FORMATTER.toFormat(LocalDate.FROM);
        LocalDate result = (LocalDate) format.parseObject("ONE2012 07 27");
        assertEquals(result, LocalDate.of(2012, 7, 27));
    }

    @Test(expectedExceptions=ParseException.class)
    public void test_toFormat_parseObject_StringParsePosition_dateTimeError() throws Exception {
View Full Code Here

    }

    @Test(expectedExceptions=ParseException.class)
    public void test_toFormat_parseObject_StringParsePosition_dateTimeError() throws Exception {
        Format format = DATE_FORMATTER.toFormat(LocalDate.FROM);
        format.parseObject("ONE2012 07 32");
    }

    @Test(expectedExceptions=NullPointerException.class)
    public void test_toFormat_Class() throws Exception {
        BASIC_FORMATTER.toFormat(null);
View Full Code Here

    public Angle(final String string) throws NumberFormatException {
        final Format format = getAngleFormat();
        final Angle theta;
        try {
            synchronized (Angle.class) {
                theta = (Angle) format.parseObject(string);
            }
        } catch (ParseException exception) {
            NumberFormatException e = new NumberFormatException(exception.getLocalizedMessage());
            e.initCause(exception);
            throw e;
View Full Code Here

    long days = 0;
    Format format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String currentTime = format.format(new Date());

    try {
      Date currentDate = (Date) format.parseObject(currentTime);
      Date targetDate = (Date) format.parseObject("2012-7-27 00:00:00");
      days = (targetDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24);
    } catch (ParseException e) {
      e.printStackTrace();
    }
View Full Code Here

    Format format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String currentTime = format.format(new Date());

    try {
      Date currentDate = (Date) format.parseObject(currentTime);
      Date targetDate = (Date) format.parseObject("2012-7-27 00:00:00");
      days = (targetDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24);
    } catch (ParseException e) {
      e.printStackTrace();
    }
   
View Full Code Here

      for (String s : Page.getLink(url)) {
        ArrayList<String[]> a = Page.scanPage(s);
        for (String[] l : a) {
          String time = l[1];
          time = time.substring(0, 11) + time.substring(15);
          Date d = (Date) formatter.parseObject(time);
          Calendar cal = Calendar.getInstance();
          cal.setTime(d);
          if (cal.get(Calendar.HOUR_OF_DAY) > 8
              && cal.get(Calendar.HOUR_OF_DAY) < 18
              && cal.get(Calendar.DAY_OF_WEEK) != 1
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.