EJB / EE :: Error - Literal Does Not Match Format String
Mar 3, 2015
I'm trying to insert some data of type date into database table using hibernate.i take the input date from an xhtml form as shown below
addEvent.xhtml
Event Date (dd-mon-yy) :
<br/>
<h:inputText id="eventdate" value="#{eventBean.eventDate}" p:required="required"
p:type="date"/>
<p/>
<h:commandButton value="Add Event" actionListener="#{eventBean.addEvent}" />
<p/>
This is my addEvent method in EventBean.java
public void addEvent(ActionEvent evt) {
uname = Util.getUname();
boolean a = EventDAO.add(this);
if ( a) {
message = "Event has been added!";
[Code] ....
While executing this..i get the following error: ORA-01861: literal does not match format string. Could it be due to any mismatch in date format (chrome browser automatically takes date in the format mm-dd-yyyy )? If yes, how do I resolve it? (I'm using Oracle database)
View Replies
ADVERTISEMENT
Jan 25, 2015
I'm trying to put together a method that formats telelphone numbers, but there's a part of my code that not working. If I enter (305)912-5458 into the variable phoneNumb I get an index is out of range error. I added a lot of system out messages so that I can try to get an idea of why the code was crashing.
public static void main(String[] args) {
int intBegin = 0;
int intEnd = 1;
int length;
String charact;
StringBuilder numbuilder = new StringBuilder();
[Code] .....
The error message I'm getting is:
run:
The length is 13
intBegin is at 0
intEnd is at 1
index is at 0
Charcter ( was not inserted
[Code] ....
View Replies
View Related
Apr 26, 2014
While doing trial and error got caught in the below scenario.
public class Crypt {
public static void main (String args[])
{
/*all I want is calculate a binary number (ex -: 22 , 34) using decimal base (10n).
*So, I have to convert 2 p into 10n form so I have to find n in terms of p . We have x as the input.
* The formula works as below.
*2p =10n
*p ln (2) =n ln (10)
*n = p [ln(2) / ln(10)]
*2 p = 10 p [ln(2) / ln(10)]
[Code] ....
View Replies
View Related
Jan 6, 2014
I have a program like below:
final String s1 = "AAA";
final String s2 = "AAA";
String s6 = s1+s2;
String s7 = "AAAAAA";
if ( s6 == s7 ){
System.out.println("s6 and s7 are same" );
}
On running, it prints "s6 and s7 are same". But if i remove the final modifier of s1 and s2 then it's not. What could be the reason?
View Replies
View Related
Sep 18, 2014
I need to use print not println to declare stuff and I need to have string literals I think that's /n. Now when I compile it just shows row1, row2 ect. Why does it work like that?
public class art {
public static void main(String[] args) {
//local variables
String row1= "***********************";
String row2= "** *** *** **";
String row3= "** ***** ***** **";
[Code] ...
View Replies
View Related
Apr 28, 2014
I am working with java project which is kind of charting room..but the problem is when am writing the query for listing the message in the conversation the error prevail in my eclipse...string literal is not properly closed by double quote...this is my java file
<%
String uname=session.getAttribute("username").toString();
String pword=session.getAttribute("password").toString();
java.util.Date dat=new Date();
int x=1;
try{
[code]....
View Replies
View Related
Jul 11, 2014
string literal is not properly closed by a double quote
View Replies
View Related
Apr 24, 2015
Why the following string fails the test below:
@Pattern(regexp = "^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*.(([0-9]{1,3})|" +
"([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$", message = "Not a well-formed email address")
View Replies
View Related
Apr 3, 2014
I have a table which contains list of regular expression and its corresponding value.I have to fetch those value and put it HASHMAP where regex as key.I have to compare the each key with the given string(input) and If matches I have to get the corresponding Value for the regex.
View Replies
View Related
Oct 15, 2014
I have 2 strings
String value ="/abc_12_1/abc234/abc/filename.txt";
String src="abc"
Sring tgt=xyz
Now I have to replace the string in variable value in case of exact match; I am trying to do the following :
if(value.contains(src)
{
value.replaceall(src,tgt);
}
Now the problem here is it replaces all the occurrence of abc in the string value and I get the below output as :
value=""/xyz_12_1/xyz234/xyz/filename.txt";
However my requirement is only in the case the value exactly matches with source the replacement shd happen. I am expecting the output like this :
String value ="/abc_12_1/abc234/xyz/filename.txt";
Also the above code is in a function which will be called multiple times and the values will keep on changing. However the target and source will remain the same always.
View Replies
View Related
Jan 1, 2015
I need a pattern that matches Hello Smith (STL Terminal) (15.0).
View Replies
View Related
Jun 12, 2014
I am trying to match the input string with range of values and getting PatternSyntaxException. below is my code
public static void main(String[] args) {
String regex="01[4-6]";
String code="015";
boolean bool=code.matches(regex);
System.out.println(bool);
}
output: true
But when i try to give range in double digits, it throws exception. What if i have to match a number(as string) between 10 to 25 or like that.
public static void main(String[] args) {
String regex="0[14-16]";
String code="015";
boolean bool=code.matches(regex);
System.out.println(bool);
}
Output:
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal character range near index 5
0[14-16]
^
View Replies
View Related
Feb 18, 2014
I have a large text file of 1 GB size. I need to print the line when a matching word is found in a particular line. Below is the code I am using. But if there are many lines that has the matching word, it's taking lot of time. Any solution to print the lines much faster.
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if(line.contains("xyz")) {
System.out.println(line);
}
}
View Replies
View Related
Dec 12, 2014
I am getting the following error:
Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '.2f'
The line it is referring to is:
System.out.println("
Toppings: ");
for (int i = 0; i < toppings.size(); i++) {
System.out.format("%-15s£%.2f
",BBQSpecial.getToppings().get(i)
.name(), BBQSpecial.getToppings().get(i).getCost());
View Replies
View Related
May 8, 2014
Alright, so let's say I have this string. I want to make it so that the string for this variable has to follow a certain format.
For example, "AAA-B", where the A's are a digit 0-9, the - is always in the same spot, and B is a letter but only from A-M. All of this for a single instance variable.
Is this possible? How could I go about doing this.
View Replies
View Related
Mar 6, 2014
In the Employee's toString, you are using the NumberFormat class to format your hourly rate and weekly pay but you are supposed to use java string formatting only (%f). You should change those to use only string formatting - no use of NumberFormat.
package coursework;
import java.text.NumberFormat;
public class Employee {
private String firstName;
private String lastName;
private int employeeId;
private double hourlyRate;
public Timecard timeCard;
[Code] .....
View Replies
View Related
Mar 21, 2014
I have a date in the following String format "2013-03-28,19:37:52.00+00:00" and post processing I am converting this to following String as per prevailing logic "2013-03-28,19:37:52.00+0000" (This is existing code and no changes have been Made here for last few years) And the using this SDFormat i.e new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.Sz") for conversion to Date Object
We are suddenly getting this exception now can't figured out what has changed ?
java.text.ParseException: Unparseable date: "2013-03-28,19:37:52.00+0000"
at java.text.DateFormat.parse(DateFormat.java:357)
View Replies
View Related
Aug 7, 2014
I am trying to do is extract numbers that are in word format in a long String, i.e. a song, and return each of their numerical values, in order to add them all up. So I'd like to calculate the sum of all of the numbers in the text. This has to work for any piece of text and for all numbers up to a trillion.
So I broke the string down into tokens and stored them in a String []. And I divided up the possible numbers in word format into:
LARGEST: thousand, million, billion, trillion
HUNDRED: hundred
TENS: twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety
UNITS: one, two, three, four, five, six, seven, eight, nine
SPECIALS: ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen
I believe that these are the only words that it will need to recognize. I began reading the tokenized string from right to left and then when I came across a unit, special or tens as the first number I hit, I would then set it's numerical value and check if the word before was also a number and whether to add or multiply etc. i.e. First number hit is a two, if the number before is sixty, then I would just add it to sixty and check the word before that and so on.
However, when implementing it, it seems like an extremely long way around it. How I could implement this in a swifter manner? An example of it working would be:
"Nine Million rockets turned Three times and met Twenty Two Aliens", it would extract, Twenty Two as 2, then 20 = 22, then extract Three as 3, and then Nine Million as 1,000,000 x 9 = 9,000,000
9,000,000 + 22 + 3 = 9,000,025
View Replies
View Related
Mar 8, 2014
This is the exception message I am getting when I run the program and I select a job from the check box and enter an hour amount.
import javax.swing.*;
import java.awt.*;
public class HourPanel extends JPanel {
private double hours;
String textField;
[Code] .....
View Replies
View Related
Jun 19, 2014
I am working on a project that just calculates simple interest based upon a principal and a percent interest rate written as .xxxx from user.
I need the Loan amount and the final interest calculation to show up as a currency with commas in appropriate areas, the Rate to be expressed as X.xxx% instead of .xxxx
I keep getting this error when I compile:
C:JavaInterestCalculator.java:46: error: incompatible types: String cannot be converted to double
principal = formatter.format(principal);
^
C:JavaInterestCalculator.java:49: error: incompatible types: String cannot be converted to double
rate = formatter.format(rate);
^
C:JavaInterestCalculator.java:52: error: incompatible types: String cannot be converted to double
totalInterest = formatter.format(totalInterest);
^
3 errors
Tool completed with exit code 1
And here is my code
import java.util.Scanner;
import java.text.NumberFormat;
import java.text.DecimalFormat;
// class declaration
public class InterestCalculator
{
// main method declaration
[Code] .....
View Replies
View Related
Mar 31, 2014
what is default literal for Boolean data type?
View Replies
View Related
Jun 3, 2014
char c=(char)-65;
This is legal but how ?? what is the value actually being stored in c ? The output is shown as .
View Replies
View Related
May 25, 2015
in Operator/Literals, it says "There is no literal representation for binary numbers in C, C++, or Java." seems "0b11001" could reprensent binary numbers?
int i = 0b100;
System.out.println(i);
the output should be 4.
View Replies
View Related
Jan 20, 2015
I thought numeric literal were by default int or doubles, depending on if have a . and numbers after the But I wrote a quick test program as listed below. I understand the float float floatA = 5.5; failed to compile since 5.5 is a literal of type double and you are trying to assign this to a floag
What I am having problems with is byte byteA = 5; 5 is a literal of type int and this is being assigned to a byte and compiler should complain.The compiler does not allow two byte values to be added and assigned to a byte since the result of the addition is an int
class literalTesting{
public static void main(String[] arg){
byte byteA = 5; // allowed WHY I thought literal is an int and assigning int to byte
byte byteB = 10; // allowed
[code]...
View Replies
View Related
Apr 23, 2014
If you write
byte b = 100; it works (implicit conversion of implicit int literal 100 to byte.
But if you have a methodvoid bla(byte b){}
And want to invoke it with a literal (which is an int by default):bla(8) then there is no implicit conversion.
Is the byte b = 100; just an exception in Java? And is it the rule that one has to explicitely cast (narrow) integer literals when passing to smaller-than-int types?
View Replies
View Related
Oct 4, 2014
In a code im writing I was curious as to instead of
contains(".")
I wanted to use
matches(" ") method instead but really having issues with the regex
I have tried //. as well as ^[.] but they give me errors.
I am just trying to match a period but was curious as to what the form was. I read a good amount of materials and seemed simple but getting errors.
View Replies
View Related