Need help in date to number conversion
Hi,
I have a doubt in a date conversion, please help me.
I executed the below query, its throwing "invalid number" error.
select * from test
where date_sid between to_number(to_char('01-05-2009','dd-mm-yyyy'),'yyyymmdd') and to_number(to_char('02-05-2009','dd-mm-yyyy'),'yyyymmdd')
date_sid column is number datatype.
In my above query i want to pass the date value like '12-05-2009'. If i check my table date_sid looks like yyyymmdd. So how to convert '12-05-2009' to 20090512 in my above query. Please help me.
Thanks.
Use to_date instead of your to_char, and to_char instead of your to_number.
That said, that's very very sad to work on date as number format.
Nicolas.
Similar Messages
-
Need help in finding the number of occurrences of a pattern.
Hi All,
I need help in finding the number of occurrences of a pattern in a table's column's data.
Consider sample data - one row's column from a table:
"S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C"
My requirement is:
I should get the count of S's which are immediately preceded by A or P.
for the above data i should get count as 3+2+1=6 (S-S-S-A, S-S-P, S-A)
The pattern data is stored as VARCHAR2 type.
Thanks in advance,
Girish G
Edited by: Girish G on Jul 21, 2011 11:22 PMI am sure there exists a better way then this one:
SQL> with dt as
2 (select 'S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C' str from dual)
3 SELECT SUM(Regexp_count(Regexp_substr(str, '(S\-?)+(A|P)+', 1,
4 Regexp_count(str, '(S\-?)+(A|P)+') - (
5 LEVEL - 1 )), 'S')) len
6 FROM dt
7 CONNECT BY LEVEL <= Regexp_count(str, '(S\-?)+(A|P)+')
8 /
LEN
6 -
I need help with my serial number. I downloaded soundbooth cs3 to restore my downloaded purchase, but my serial number is not being accepted. I have 16 more days to resolve this. I don't need tech support, I just need the software I purchased to work for me. That's not to much to ask, is it? Can anyone from adobe help me please?
ChrisError "The serial number is not valid for this product" | Creative Suite
-
I am printing a calendar and certain events will be helds on certain dates.
One can edit the event if it has not passed the date. Events in the past can be viewed but not edited.
When I query the database the date must be formatted dd-MMM-yy
I am able to get today's date by doing this:
java.util.Date today = new java.util.Date();
String formatString = "dd-MMM-yy";
SimpleDateFormat sdf = new SimpleDateFormat(formatString);
String today_str = sdf.format(today);
My code for printing the calendar: I left out some of the table formatting in the JSP page.
GregorianCalendar d = new GregorianCalendar();
int today = d.get(Calendar.DAY_OF_MONTH);
int month = d.get(Calendar.MONTH);
d.set(Calendar.DAY_OF_MONTH,1);
int weekday = d.get(Calendar.DAY_OF_WEEK);
for(int i = Calendar.SUNDAY; i < weekday; i++)
out.print("<td> </td>");
do {
int day = d.get(Calendar.DAY_OF_MONTH);
out.print("<td>" + day + "</td>");
String formatString = "dd-MMM-yy";
SimpleDateFormat sdf = new SimpleDateFormat(formatString);
//if(event exists on this day
// Get results
// print link for viewing
// if (after today) print link for edit
if(weekday == Calendar.SATURDAY)
out.println("</tr><tr valign=top>");
d.add(Calendar.DAY_OF_MONTH,1);
weekday = d.get(Calendar.DAY_OF_WEEK);
} while(d.get(Calendar.MONTH) == month);
if(weekday != Calendar.SUNDAY)
System.out.println();
The part I need help on is this:
//if(event exists on this day
// Get results
// print link for viewing
// if (after today) print link for edit
I'm looping through each day of the month to print the days. I have the month, day, year as integers. How can I create a date object out of that and compare it to today's date to test if it's before or after today???
All the function in the Date class that I think would do this have been deprecated.Need Help with Dates
Here is some information about dates:
There are many edible palm fruits, and one of the most widespread and favored of these is the data (Phoenix dactylifera). Dates were cultivated in ancient land from Mesopotamia to prehistoric Egypt, possibly as early as 6000 B.C. Then--as now--dates were a staple for the natives of those dry regions. Much later, Arabs spread dates around northern Africa, and dates were introduced into California by the Spaniards in 1765, around Mission San Ignacio.
The date prefers dry, hot climates, because date fruits are injured at temperatures of 20 degrees F, and the damp climate of the California coast was not favorable for fruit production. In the mid-1800s, the date industry developed in California's hot interior valleys and in Arizona. Now the date industry in the United States is localized mostly in the Coachella Valley, where the sandy soils permit the plants to be deeply irrigated. Today the new varieties, mostly introduced in this century, produce about 40 million pounds of dates per annum, or over 60% of the dates consumed in this country. The rest are imported mainly from Persia. According to one survey, about one million people are engaged entirely in date palm cultivation worldwide.
Hope that helps. -
I need help getting the license number for Adobe Photoshop Elements. However, It doesn't recognize me as an authorized user. Can someone help?@
I am having the same problem...did you ever fix it?
-
Need help in date Validation Urgent
Hi ,
We need help in Date Validation.
we have 2 Date fields on the form Start Date, End Date
The requirement is: End Date (May not be greater than 30 years from the start date).
I have written following script on End Date Exit event. But the problem is its calculating 30 years from the Current Date not from the Start Date
var tDate = util.scand("mm/dd/yyyy", new Date());
var M = tDate.getMonth();
var D = tDate.getDate();
var Y = tDate.getFullYear();
var SRes = util.printd("yyyy-mm-dd", new Date((Y+30), M,D) );
//app.alert(SRes)if (SRes <= this.rawValue){
app.alert("May not be greater than 30 years from the start date")
xfa.host.setFocus(
this);}
can someone please help me
Regards,
JayHi,
You'll need to get javascript date from LCD field, and calculate & compare with the future date in javascript date.
try following script;
var sDate = StartDate.rawValue;
var wkStartDate = util.scand("yyyy-mm-dd", sDate);
var nYear = wkStartDate.getFullYear();
var nMonth = wkStartDate.getMonth();
var nDay = wkStartDate.getDate();
var wkFutureDate = new Date(nYear + 30 , nMonth, nDay);
sDate = EndDate.rawValue;
var wkEndDate = util.scand("yyyy-mm-dd", sDate);
if (wkEndDate.getTime() > wkFutureDate.getTime()){
xfa.host.messageBox("May not be greater than 30 years from the start date");
xfa.host.setFocus(this); -
Need Help with data type conversion
Hello People,
I am new to java, i need some help with data type conversion:
I have variable(string) storing IP Address
IPAddr="10.10.103.10"
I have to call a library function which passes IP Address and does something and returns me a value.
The problem I have is that external function call in this library excepts IP Address in form of a byte array.
Here is the syntax for the function I am calling through my program
int createDevice (byte[] ipAddress).
now my problem is I don't know how to convert the string IPAddr variable into a byte[] ipAddress to pass it through method.Class InetAddress has a method
byte[] getAddress() You can create an instance using the static method getByName() providing the IP address string as argument. -
Help needed in converting date to number
Hi,
I am trying to execute the below query, its failing with "invalid number" error.
select * from process_status
where time_process > to_char('&3','yyyymmdd')
time_process is the "number" datatype.
Details:
SQL> select * from process_status
2 where time_process > to_char('&3','yyyymmdd');
Enter value for 3: 01-MAY-09
old 2: where time_process > to_char('&3','yyyymmdd')
new 2: where time_process > to_char('01-MAY-09','yyyymmdd')
where time_process > to_char('01-MAY-09','yyyymmdd')
ERROR at line 2:
ORA-01722: invalid number
If I execute the below query its working fine, I am facing problem only when I pass the date explicitly to the query. Please help me on converting the date to number format.
select * from etl_process_status
where time_process > '20090501'
and rownum < 3;
Thanksas others have said, it would be best to have your time_process column stored as a date in oracle, if it contains dates.
The reason for this is because if you store your dates as a number, you have removed information from Oracle that says "This is a date", so when Oracle comes to try and estimate the number of rows greater than a specific value, it can no longer guess correctly, since it's basing its guess on that column being a number.
There are lots more numbers between '20091201' and '20091101' than there are days between 1st November and 1st December.
By hiding the fact that your data is a date, you could throw your execution plan off and end up with sub-optimal performance.
In short, store your data in the correct column format! -
I need help restoring data from my time machine.
1) On the time machine, where do I find the TRASH file that is located on the dock in my desktop? I'd like to restore that to a prior date but can't find it.
2) I DID A VERY BAD THING & need help to get back to where I was before. I wanted to delete files that were taking up lots of space. My OTHER section was using 160G. I downloaded OmniDiskSweep and found that 120G was being used by my virtual machine (I run Quicken in Windows, through VMware). I started to delete files that were called Snapshots assuming these were the snapshots that the program regularly takes of my files. Apparently they were not. I also deleted the program Windows XP Professional because that was never used. When I try to open VM or quicken program, it says it is missing a particular snapshot, i.e. Snapshot 11104. I deleted about 20 of these. I left all the other files that said Windows XP Home Edition. But now it shows that I only have the Professional Edition, even though that's what I deleted. I'm trying to restore from Time Machine and it looks like the information is not there - I've tried various different backups and nothing seems to have the information I need. The earliest back up I have is from 5/7 when I started time machine on a new external 1TB HD. Would that have the information I need since it's the very first back up? Please Help.I am assuming it's real data because it's taking up storage on my HD. It falls in the category "other" and the total of this section is 160G. Here is a snapshot of the virtual machine.
I also took a shot of the VM snapshots & it tells how much space is being taken up by the snapshots.
I've now changed the number of snapshots taken down to 12 (didn't know I had this option) & I can delete alot of the 21 snapshots that have already been saved. I have no idea how much of the HD was set aside for the VM because someone else installed it for me 5 years ago. I've had enough problems with it over the years that I've wanted to switch to Quicken for Mac or find another financial program to use. I've upgraded the VM 2x over the years, but didn't want to spend $100 for Version 5. I understand the concept of a VM but that's about all.
I did do the disk cleanup in Windows on the C drive. I deleted 700 MB of temporary files and then compressed 4G of data down to 2G. While the cleanup was progressing it said that the C drive was 30.99G and 78% of it was free. That just doesn't make sense to me. It recommended a defrag, so I did that also.
I'm pretty sure it's real data because I recently had to switch from a 320G external HD for TM, to a 1T HD. One TM backup was over 300G which I found to be excessive because I basically use my computer for mail, some word processing, and my financial data.
Thanks again for all your help. I really appreciate it. -
Need help pulling data from an outside file into my array. Please help =)
Hi,
I need help adapting my array to read the interest rates from an outside file. Here is my code and the outside file I wrote. Please help. Oh, the array in question is on line 259, inside of my calculation() method.
Thanks...
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
public class Workshop5 extends JFrame implements ActionListener
//declare gui components
//declare labels
JPanel contentPane = new JPanel();
JPanel graphPane = new JPanel();
JLabel instructionLabel = new JLabel();
JLabel amountLabel = new JLabel();
JLabel orLabel = new JLabel();
JLabel comboBoxLabel = new JLabel();
JLabel termLabel = new JLabel();
JLabel rateLabel = new JLabel();
JLabel calcLabel = new JLabel();
JLabel paymentLabel = new JLabel();
JLabel tableLabel = new JLabel();
//declare font object
Font labelFont = new Font("Tahoma", Font.PLAIN, 16);
//declare text fields
JTextField amountField = new JTextField(20);
JTextField termField = new JTextField(20);
JTextField rateField = new JTextField(20);
JTextField paymentField= new JTextField(20);
//declare combo box for loan selection
JComboBox comboBox = new JComboBox();
//declare button group and radio buttons
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButton enterRadioButton = new JRadioButton("Enter amount, term, & rate", true);
JRadioButton selectRadioButton = new JRadioButton("Select a preset term/rate loan", false);
//declare button objects
JButton clearButton = new JButton();
JButton calcButton = new JButton();
JButton quitButton = new JButton();
//declare text area for amortization
JTextArea amortTextArea = new JTextArea();
JTextArea testTextArea = new JTextArea();
//declare scroll bar for amortization table
JScrollPane scrollPane = new JScrollPane(amortTextArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
public Workshop5()
instructionLabel.setText("Choose one of the following payment calculation options:");
instructionLabel.setFont(new Font("Tahoma",Font.PLAIN,16));
//adds both buttons to button group
buttonGroup.add(enterRadioButton);
buttonGroup.add(selectRadioButton);
enterRadioButton.setFont(labelFont);
enterRadioButton.setBackground(Color.WHITE);
enterRadioButton.setContentAreaFilled(false);
enterRadioButton.addActionListener(this); //adds action listener to enter radio button
orLabel.setText("OR");
orLabel.setFont(new Font("Tahoma",Font.BOLD,18));
selectRadioButton.setFont(labelFont);
selectRadioButton.setBackground(Color.WHITE);
selectRadioButton.setContentAreaFilled(false);
selectRadioButton.addActionListener(this); //adds action listener to select radio button
amountLabel.setText("Enter mortgage amount");
amountLabel.setFont(new Font("Tahoma", Font.PLAIN,16));
amountField.requestFocusInWindow();
termLabel.setText("Enter term length in years:");
termLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
rateLabel.setText("Enter interest rate:");
rateLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBoxLabel.setText("Select a loan:");
comboBoxLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBox.setBackground(new Color(255,255,255));
comboBox.setFont(new Font("Tahoma", Font.PLAIN, 14));
comboBox.setEnabled(false);
ComboBox();
calcLabel.setText("Press Calculate button to determine monthly payment.");
calcLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
calcButton.setText("Calculate");
calcButton.setFont(new Font("Tahoma", Font.BOLD, 14));
calcButton.addActionListener(this);
//define monthly payment label
paymentLabel.setText("Monthly payment:");
paymentLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
//define monthly payment text field
paymentField.setFont(new Font("Tahoma", Font.BOLD,16));
paymentField.setBackground(new Color(255,255,255));
paymentField.setEditable(false);
//define clear button
clearButton.setText("Clear");
clearButton.setFont(new Font("Tahoma", Font.BOLD,14));
clearButton.addActionListener(this);
//define quit button
quitButton.setText("Quit");
quitButton.setFont(new Font("Tahoma", Font.BOLD,14));
quitButton.addActionListener(this);
tableLabel.setText("Amoritization Table");
tableLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
graphPane.setBackground(Color.WHITE);
//add components to content
getContentPane().add(contentPane);
contentPane.setLayout(null);
addComponent(contentPane, instructionLabel, 80,10,450,26);
addComponent(contentPane, enterRadioButton, 30,40,220,30);
addComponent(contentPane, orLabel, 280,40,100,30);
addComponent(contentPane, selectRadioButton, 335,40,350,30);
addComponent(contentPane, amountLabel, 100,80,220,26);
addComponent(contentPane, amountField, 300,80,150,26);
addComponent(contentPane, termLabel, 15,125,200,30);
addComponent(contentPane, termField, 195,125,125,30);
addComponent(contentPane, rateLabel, 62,160,200,30);
addComponent(contentPane, rateField, 195,165,125,30);
addComponent(contentPane, comboBoxLabel, 400,125,200,26);
addComponent(contentPane, comboBox, 400,155,150,30);
addComponent(contentPane, calcLabel, 100,200,400,30);
addComponent(contentPane, calcButton, 250,240,100,30);
addComponent(contentPane, paymentLabel, 150,285,200,30);
addComponent(contentPane, paymentField, 300,285,100,30);
addComponent(contentPane, clearButton, 100,330,100,30);
addComponent(contentPane, quitButton, 400,330,100,30);
addComponent(contentPane, tableLabel, 200,370,300,26);
addComponent(contentPane, scrollPane, 10,400,450,360);
addComponent(contentPane, graphPane, 475,400,305,360);
//add window listener to close window when user presses X
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
pack();
//method to add components
private void addComponent(Container container, Component c, int x, int y, int width, int height)
c.setBounds(x, y, width, height);
container.add(c);
//action performed method
public void actionPerformed(ActionEvent event)
Object source = event.getSource();
if (source == calcButton)
Calculate();
if (source == clearButton)
Clear();
if (source == quitButton)
Exit();
//defines active area based on user selection of mortgage calculation method
//if user chooses to enter the mortgage manually, combo box fields are inactive
if (source == enterRadioButton)
comboBox.setEnabled(false);
termField.setEnabled(true);
termField.setEditable(true);
rateField.setEnabled(true);
rateField.setEditable(true);
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
//if user chooses to select from a preset mortgage, rate and term fields are inactive
if (source == selectRadioButton)
comboBox.setEnabled(true);
termField.setEnabled(false);
termField.setEditable(false);
rateField.setEnabled(false);
rateField.setEditable(false);
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of action performed method
//combo box method
public void ComboBox()
String[] LoanArray = {" 7 years at 5.35 %", " 15 years at 5.50 %", " 30 years at 5.75 %"};
for (int i = 0; i < LoanArray.length; i++)
comboBox.addItem(LoanArray);
}//end combo box method
//calculation method
void Calculate()
//resets fields
paymentField.setText("");
amortTextArea.setText("");
//calculation variables
NumberFormat currency = NumberFormat.getCurrencyInstance();
int [] termArray = {7, 15, 30}; //array of years
double [] yearlyInterestArray = {5.35, 5.5, 5.75}; //array of interest
int totalMonths = 0; //total months
double Loan = 0.0; //amount of loan
double MonthlyInterest = 0.0; //monthly interest rate
double Payment = 0.0; //calculate payment
double monthlyPayment = 0.0; //calculate monthly payment
double Interest = 0.0; //variable for Interest Array input
int Term = 0; //variable for Term Array input
double NewMonthlyInterest = 0.0; //new interest amount
double NewLoan = 0.0; //new loan amount
double Reduction = 0.0; //principle reduction
//validate input
try
Loan = Double.parseDouble(amountField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid Entry. Please enter valid loan amount.", "Error", JOptionPane.WARNING_MESSAGE);
//resets input fields after error message
amountField.setText("");
amountField.requestFocusInWindow();
//if select button is chosen
if (selectRadioButton.isSelected())
int index = comboBox.getSelectedIndex();
Term = termArray[index];
Interest = yearlyInterestArray[index];
//if user chooses to enter mortgage information
else
if (enterRadioButton.isSelected())
//validates input
try
Term = Integer.parseInt(termField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid term length in years.", "Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
termField.setText("");
termField.requestFocusInWindow();
try
Interest = Double.parseDouble(rateField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid rate (without percent symbol).","Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
rateField.setText("");
rateField.requestFocusInWindow();
//perform calculations
if (Loan > 0)
Loan = Double.parseDouble(amountField.getText());
MonthlyInterest = (Interest / 12)/100;
totalMonths = Term * 12;
monthlyPayment = Loan * MonthlyInterest *(Math.pow((1 + MonthlyInterest), totalMonths)/(Math.pow((1 + MonthlyInterest), totalMonths)-1));
paymentField.setText("" + currency.format(monthlyPayment));
//send information to amortization text area
amortTextArea.append("Number\t");
amortTextArea.append(" Amount\t");
amortTextArea.append("Interest\t");
amortTextArea.append("Principle\t");
amortTextArea.append("Balance\n");
NewLoan = Loan;
for (int i = 1; i <= totalMonths; i++)
NewMonthlyInterest = MonthlyInterest * NewLoan;
Reduction = monthlyPayment - NewMonthlyInterest;
NewLoan = NewLoan - Reduction;
amortTextArea.append(" " + i +"\t");
amortTextArea.append(" " + currency.format(monthlyPayment) + "\t");
amortTextArea.append(" " + currency.format(NewMonthlyInterest)+ "\t");
amortTextArea.append(" " + currency.format(Reduction) + "\t");
amortTextArea.append(" " + currency.format(NewLoan) + "\n");
//resets fields if loan amount is less than zero
if((Loan <= 0 || Term <= 0 || Interest <= 0))
paymentField.setText("");
amortTextArea.setText("");
}//end calcualtion method
//clear method
void Clear()
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of clear method
//main method
public static void main(String args[])
Workshop5 f = new Workshop5();
f.setTitle("Carol's Mortgage Calculator");
f.setBounds(200,100,800,800);
f.setResizable(false);
f.setVisible(true);
}//end of main method
//exit method
void Exit()
System.exit(0);
}//end of exit method
}//program end
My data file is called: "InterestData.dat" and only contains the following text:
5.35, 5.5, 5.75Ok, now I am getting this error message:
cannot resolve symbol method lenght()
Please help me out here, this is due tomorrow and I've been killing myself on it...
attaching program with revised code included, see beginning of calculation method line 250:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.* ;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
public class Workshop5 extends JFrame implements ActionListener
//declare gui components
//declare labels
JPanel contentPane = new JPanel();
JPanel graphPane = new JPanel();
JLabel instructionLabel = new JLabel();
JLabel amountLabel = new JLabel();
JLabel orLabel = new JLabel();
JLabel comboBoxLabel = new JLabel();
JLabel termLabel = new JLabel();
JLabel rateLabel = new JLabel();
JLabel calcLabel = new JLabel();
JLabel paymentLabel = new JLabel();
JLabel tableLabel = new JLabel();
//declare font object
Font labelFont = new Font("Tahoma", Font.PLAIN, 16);
//declare text fields
JTextField amountField = new JTextField(20);
JTextField termField = new JTextField(20);
JTextField rateField = new JTextField(20);
JTextField paymentField= new JTextField(20);
//declare combo box for loan selection
JComboBox comboBox = new JComboBox();
//declare button group and radio buttons
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButton enterRadioButton = new JRadioButton("Enter amount, term, & rate", true);
JRadioButton selectRadioButton = new JRadioButton("Select a preset term/rate loan", false);
//declare button objects
JButton clearButton = new JButton();
JButton calcButton = new JButton();
JButton quitButton = new JButton();
//declare text area for amortization
JTextArea amortTextArea = new JTextArea();
JTextArea testTextArea = new JTextArea();
//declare scroll bar for amortization table
JScrollPane scrollPane = new JScrollPane(amortTextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
public Workshop5()
instructionLabel.setText("Choose one of the following payment calculation options:");
instructionLabel.setFont(new Font("Tahoma",Font.PLAIN,16));
//adds both buttons to button group
buttonGroup.add(enterRadioButton);
buttonGroup.add (selectRadioButton);
enterRadioButton.setFont(labelFont);
enterRadioButton.setBackground(Color.WHITE);
enterRadioButton.setContentAreaFilled(false);
enterRadioButton.addActionListener(this); //adds action listener to enter radio button
orLabel.setText("OR");
orLabel.setFont(new Font("Tahoma",Font.BOLD,18));
selectRadioButton.setFont(labelFont);
selectRadioButton.setBackground(Color.WHITE);
selectRadioButton.setContentAreaFilled(false);
selectRadioButton.addActionListener (this); //adds action listener to select radio button
amountLabel.setText("Enter mortgage amount");
amountLabel.setFont(new Font("Tahoma", Font.PLAIN,16));
amountField.requestFocusInWindow();
termLabel.setText("Enter term length in years:");
termLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
rateLabel.setText("Enter interest rate:");
rateLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBoxLabel.setText("Select a loan:");
comboBoxLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBox.setBackground(new Color(255,255,255));
comboBox.setFont(new Font("Tahoma", Font.PLAIN, 14));
comboBox.setEnabled(false);
ComboBox();
calcLabel.setText("Press Calculate button to determine monthly payment.");
calcLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
calcButton.setText("Calculate");
calcButton.setFont(new Font("Tahoma", Font.BOLD, 14));
calcButton.setBackground(new Color(202,255,112));
calcButton.addActionListener(this);
//define monthly payment label
paymentLabel.setText("Monthly payment:");
paymentLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
//define monthly payment text field
paymentField.setFont (new Font("Tahoma", Font.BOLD,16));
paymentField.setBackground(new Color(255,255,255));
paymentField.setEditable(false);
//define clear button
clearButton.setText("Clear");
clearButton.setFont(new Font("Tahoma", Font.BOLD,14));
clearButton.setBackground(new Color(202,255,112));
clearButton.addActionListener(this);
//define quit button
quitButton.setText("Quit");
quitButton.setFont(new Font("Tahoma", Font.BOLD,14));
quitButton.setBackground(new Color(202,255,112));
quitButton.addActionListener(this);
//define label for amortization table
tableLabel.setText ("Amoritization Table");
tableLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
graphPane.setBackground(Color.WHITE);
//add components to content
getContentPane().add(contentPane);
contentPane.setLayout(null);
addComponent(contentPane, instructionLabel, 80,10,450,26);
addComponent(contentPane, enterRadioButton, 30,40,220,30);
addComponent(contentPane, orLabel, 280,40,100,30);
addComponent(contentPane, selectRadioButton, 335,40,350,30);
addComponent(contentPane, amountLabel, 100,80,220,26);
addComponent(contentPane, amountField, 300,80,150,26);
addComponent(contentPane, termLabel, 15,125,200,30);
addComponent(contentPane, termField, 195,125,125,30);
addComponent(contentPane, rateLabel, 62,160,200,30);
addComponent(contentPane, rateField, 195,165,125,30);
addComponent(contentPane, comboBoxLabel, 400,125,200,26);
addComponent(contentPane, comboBox, 400,155,150,30);
addComponent(contentPane, calcLabel, 100,200,400,30);
addComponent(contentPane, calcButton, 250,240,100,30);
addComponent(contentPane, paymentLabel, 150,285,200,30);
addComponent(contentPane, paymentField, 300,285,100,30);
addComponent(contentPane, clearButton, 100,330,100,30);
addComponent(contentPane, quitButton, 400,330,100,30);
addComponent(contentPane, tableLabel, 200,370,300,26);
addComponent(contentPane, scrollPane, 10,400,450,360);
addComponent(contentPane, graphPane, 475,400,305,360);
//add window listener to close window when user presses X
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
pack();
//method to add components
private void addComponent(Container container, Component c, int x, int y, int width, int height)
c.setBounds(x, y, width, height);
container.add(c);
//action performed method
public void actionPerformed(ActionEvent event)
Object source = event.getSource();
if (source == calcButton)
Calculate();
if (source == clearButton)
Clear();
if (source == quitButton)
Exit();
//defines active area based on user selection of mortgage calculation method
//if user chooses to enter the mortgage manually, combo box fields are inactive
if (source == enterRadioButton)
comboBox.setEnabled(false);
termField.setEnabled(true);
termField.setEditable(true);
rateField.setEnabled(true);
rateField.setEditable(true);
amountField.setText ("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText ("");
amortTextArea.setText("");
//if user chooses to select from a preset mortgage, rate and term fields are inactive
if (source == selectRadioButton)
comboBox.setEnabled(true);
termField.setEnabled(false);
termField.setEditable(false);
rateField.setEnabled (false);
rateField.setEditable(false);
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText ("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of action performed method
//combo box method
public void ComboBox()
String[] LoanArray = {" 7 years at 5.35 %", " 15 years at 5.50 %", " 30 years at 5.75 %"};
for (int i = 0; i < LoanArray.length; i++)
comboBox.addItem(LoanArray);
}//end combo box method
//calculation method
void Calculate()
//resets fields
paymentField.setText("");
amortTextArea.setText("");
//calculation variables
NumberFormat currency = NumberFormat.getCurrencyInstance();
//declare input stream object
InputStream istream;
//create a file object to refer to the outside file
File interestData = new File("InterestFile.dat");
//assign instream to the new file object
istream = new FileInputStream(interestData);
try
StringBuffer sb = new StringBuffer();
BufferedReader in = new BufferedReader(new FileReader(interestData));
String line = "";
while((line = in.readLine()) != null)
sb.append(line);
in.close();
String fileData = sb.toString();
String[] splitData = fileData.split(", ");
double [] yearlyInterestArray = new double[splitData.length()];
for(int j = 0; j < splitData.length(); j++)
yearlyInterestArray[j] = new Double(splitData[j]).doubleValue();
catch (IOException e)
JOptionPane.showMessageDialog(null, "File does not exist." + e.getMessage());
int [] termArray = {7, 15, 30}; //array of years
double [] yearlyInterestArray = { 5.35, 5.5, 5.75}; //array of interest
int totalMonths = 0; //total months
double Loan = 0.0; //amount of loan
double MonthlyInterest = 0.0; //monthly interest rate
double Payment = 0.0; //calculate payment
double monthlyPayment = 0.0; //calculate monthly payment
double Interest = 0.0; //variable for Interest Array input
int Term = 0; //variable for Term Array input
double NewMonthlyInterest = 0.0; //new interest amount
double NewLoan = 0.0; //new loan amount
double Reduction = 0.0; //principle reduction
//validate input
try
Loan = Double.parseDouble(amountField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid Entry. Please enter valid loan amount.", "Error", JOptionPane.WARNING_MESSAGE);
//resets input fields after error message
amountField.setText("");
amountField.requestFocusInWindow ();
//if select button is chosen
if (selectRadioButton.isSelected())
int index = comboBox.getSelectedIndex ();
Term = termArray[index];
Interest = yearlyInterestArray[index];
//if user chooses to enter mortgage information
else
if (enterRadioButton.isSelected())
//validates input
try
Term = Integer.parseInt(termField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid term length in years.", "Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
termField.setText("");
termField.requestFocusInWindow();
try
Interest = Double.parseDouble(rateField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid rate (without percent symbol).","Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
rateField.setText("");
rateField.requestFocusInWindow();
//perform calculations
if (Loan > 0)
Loan = Double.parseDouble(amountField.getText ());
MonthlyInterest = (Interest / 12)/100;
totalMonths = Term * 12;
monthlyPayment = Loan * MonthlyInterest *(Math.pow ((1 + MonthlyInterest), totalMonths)/(Math.pow((1 + MonthlyInterest), totalMonths)-1));
paymentField.setText("" + currency.format(monthlyPayment));
//send information to amortization text area
amortTextArea.append("Number\t");
amortTextArea.append(" Amount\t");
amortTextArea.append("Interest\t");
amortTextArea.append("Principle\t");
amortTextArea.append("Balance\n");
NewLoan = Loan;
for (int i = 1; i <= totalMonths; i++)
NewMonthlyInterest = MonthlyInterest * NewLoan;
Reduction = monthlyPayment - NewMonthlyInterest;
NewLoan = NewLoan - Reduction;
amortTextArea.append(" " + i +"\t");
amortTextArea.append (" " + currency.format(monthlyPayment) + "\t");
amortTextArea.append(" " + currency.format(NewMonthlyInterest)+ "\t");
amortTextArea.append(" " + currency.format(Reduction) + "\t");
amortTextArea.append(" " + currency.format(NewLoan) + "\n");
//resets fields if loan amount is less than zero
if((Loan <= 0 || Term <= 0 || Interest <= 0))
paymentField.setText("");
amortTextArea.setText("");
}//end calcualtion method
//clear method
void Clear()
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of clear method
//main method
public static void main(String args[])
Workshop5 f = new Workshop5();
f.setTitle("Carol's Mortgage Calculator");
f.setBounds(200,100,800,800);
f.setResizable(false);
f.setVisible(true);
}//end of main method
//exit method
void Exit()
System.exit(0);
}//end of exit method
}//program end -
Need help correcting message error number
Hello, i need help correcting message number for running archiving test runs.
05.08.2011 08:31:42 Message number 999999 reached. Log is full BL 252 E
05.08.2011 08:31:42 Job cancelled after system exception ERROR_MESSAGE 00 564 A
Any help wopuld be appreciated.
Regards.Summary
Symptom
One or several database tables of the application log contain too many entries.
The following database tables belong to the application log:
- BALHDR (all releases)
- BALHDRP(< 4.6C)
- BALM (< 4.6C)
- BALMP (< 4.6C)
- BALC (< 4.6C)
- BALDAT (>= 4.6C)
- BAL_INDX (all releases)
Other terms
RSSLG200,
RSSLGK90,
SLG2,
application log,
log
delete,
performance
Reason and Prerequisites
The application log is a tool to collect, save and display logs.
Many different applications collect messages in the application log which contain information or messages for the end user. The application automatically log serves as a temporary storage for messages. The logs are written on the database but they are not automatically deleted.
There is no general procedure for switching the application log on or off. Some applications provide this option or they offer the option of reducing the number of entries created. (See Notes 91519, 183960, 141244).
The expiration date of application logs
A log usually has an expiration date, which is set by the application, that calls the 'Application log' tool. If the application log does not set an expiration date, the 'Application log' tool sets the expiration date as 12/31/2098 or 12/31/9999,depending on the release, which allows the logs to stay in the system for as long as possible. The end user cannot set the expiration date. The expiration date does not mean that logs which have reached that date will automatically be deleted. It is used to control the deletion of logs when you call the Deletion report. The DEL_BEFORE flag in the BALHDR table determines whether or not the log can be deleted even before the expiration date is reached.
DEL_BEFORE= SPACE means that the log can be deleted before the expiration date is reached. (Default value)
DEL_BEFORE='X' means that the log can only be deleted after the expiration date.
Solution
Deleting the logs of the application log.
Releases >= 4.6A:
=====================================================================
In Releases >= 4.6A, use Transaction SLG2.
On the selection screen you can restrict the amount of logs to be deleted:
The 'Object' and 'Subobject' fields specify the application area in which the logs were written (see F4 Help).
The 'External Identification' field specifies the number which was provided for this log by the application.
o If you also want to delete logs which have not reached the expiration date you must set the option "Also logs which can be deleted before the expiration date".
Select 'Help with application' in Transaction SLG2 for further explanation of the procedure for deleting.
SLG2 is a report transaction. The corresponding report is SBAL_DELETE. At regular intervals, this can be scheduled as a background job.
Releases < 4.6A:
=====================================================================
For Releases < 4.6A, note the following instructions:
In general, the deletion of application logs can be carried out in two steps:
1. Report RSSLG200: Deletion of all logs which expired:
Use report RSSLG200 to delete all logs whose expiration date is reached or exceeded. (This report is not yet available in the standard in Release 3.0F. In this case, the report can be installed in advance; see corrections attached to this note).
As of Release 3.1H, Report RSSLG210 is also available. This report allows the definition of a job that runs regularly and deletes such logs.
2. Report RSSLGK90: Deleting all logs for which a deletion is allowed before expiration:
Sometimes, step 1 does not delete enough logs. The reason for this might be that the expiration date of the logs is too far in the future or that no expiration date has been defined at all (in this case, depending
on the release, the assumed expiration date is 12/31/2098 or 12/31/9999)
Use report RSSLGK90 for these logs.
When you execute this report, you can restrict the logs to be deleted in a selection screen:
The fields 'Object' and 'Subobject' specify the application area which wrote the logs (see F4 help).
The field 'External number' indicates the number which was assigned by the application for this log.
Field 'Log class' indicates the importance of the log.
NOTE: By default, this field contains the value '4', this means only logs with additional information. If you want to delete all logs, enter the value '1' in this field. All logs with log class '1' or higher will then be deleted.
The fields 'To date' and 'Until time' refer to the creation date of a log.
If you enter 12/31/1998 and 23:59:59, you get all logs created in and before 1998
NOTES:
Client-dependency:
Note that the application log tables are client-dependent. Therefore, you must delete data in each client.
Which applications create entires in the application log:
To determine which applications create the logs, look in Table BALHDR to see which objects the logs were created for ( Transaction SE16, Table BALHDR, Field OBJECT). You can find the text description for the object in Table BALOBJT. The application is usually derived from the name and text of the object. The log is displayed in Transaction SL61. The display is restricted to certain objects, among other things.
Database error:
If very many data exists on the DB, Report RSSLGK90 might cause problems. In this case, implement Note 138715.
In very rare cases a dump is created even after Note 138715 was implemented:
ABAP/4 runtime error DBIF_RSQL_SQL_ERROR
SQL error 1555 occurred accessing table "BALHDR "
Database error text...: "ORA-01555: snapshot too old
If you cannot correct the error by means of database utilities, Note 368700 provides a way to bypass this error.
Report RSSLG200 can also run into problems. In this case, use the correction for Report RSSLG200 attached to this Note.
Expiration date in Report RSSLGK90:
There are logs on the database which may only be deleted explicitly after the expiration date (flag DEL_BEFORE = 'X' in table BALHDR). These logs are not deleted in advance by report RSSLGK90. Since, however, this flag is used very rarely, you can ignore this data.
Restriction of the quantity of log data by the application:
To avoid large quantities of logs from different applications, also refer to the following notes:
- 91519
- 183960
- 141244
Archiving logs:
As of Release 6.20, it has been possible to archive logs.
The logs are archived via archiving object BC_SBAL.
The archiving programs are started via Transaction SARA (archive administration).
Via Support Packages, the archiving of application logs has been made available for Releases 4.6C (SAPKB46C27), 4.6D (SAPKB46D17), and 6.10 (SAPKB61011) as well.
Header Data
Release Status: Released for Customer
Released on: 04.08.2005 13:55:45
Master Language: German
Priority: Recommendations/additional info
Category: Consulting
Primary Component: BC-SRV-BAL Basis Application Log
Affected Releases
Software
Component Release From
Release To
Release And
subsequent
SAP_APPL 30 30F 31I
SAP_APPL 40 40A 40B
SAP_APPL 45 45A 45B
SAP_BASIS 46 46A 46D X
SAP_BASIS 60 610 640 X
Corrections Instructions
Correction
Instruction Valid
from Valid
to Software
Component Last
Modifcation
158903 30F 30F SAP_APPL 16.05.2000 07:13:08
162069 31H 45B SAP_APPL 16.05.2000 07:16:07
Related Notes
1009281 - LAW: Runtime error CONNE_IMPORT_WRONG_COMP_TYPE
856006 - Mass processing saves unnecessary logs
737696 - Add. info on upgrade to SAP R/3 Enterprise 4.70 Ext. 2 SR1
706478 - Preventing Basis tables from increasing considerably
637683 - Add info about upgrade to SAP R/3 Enterprise Core 4.70 Ext 2
587896 - Add. info on upgrade to SAP R/3 Enterprise Core 4.70 SR1
540019 - Report RJBTPRLO does not work correctly
400687 - Delete application log: DBIF_RSQL_INVALID_CURSOR
390062 - Additional information about upgrading to 4.6C SR2
370601 - Composite SAP note: APO 3.0 and 3.1 performance
365602 - M/AM: Sales agent determination log - perf.
327285 - Additions to upgrade to 4.6C SR1
183960 - ALE: Deactivating application logs for data transfers
141244 - Deactivating the application log during data transfer
138715 - RSSLGK90: Too many lock entries in the database
118314 - Installing the interface to a separate EH&S
91519 - Deleting logs of the application log
Print Selected Notes (PDF)
Attributes
Attribute Value
Transaction codes BALC
Transaction codes BALM
Transaction codes CLEAR
Transaction codes HIER
Transaction codes SARA
Transaction codes -
Need help with date range searches for Table Sources in SES
Hi all,
I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
I am using SES 10.1.8.3 on Windows 32.
My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
TRACKNUM Varchar2
TITLE Varchar2
SUMMARY CLOB
SYMBOLCODE Varchar2
Timestamp Date
OBSDATE Date
GEOM SDO_GEOMETRY
I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
Schedule crawls and indexes entire REPORTS table.
In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 10-MAR-07, 22-SEP-07, 02-FEB-08, etc.)
And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
Thanks very much, in advance….raford,
Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
thanks very much! -
Date to number conversion?
I want to select a number of rows created within last week.
To do it I use a select statement with:
WHERE sysdate-o.created_on <= days;
(days is a number, created_on is a date)
Everything works fine, but I get warnings like this one:
PLW-07204: conversion away from column type may result in sub-optimal query plan
I suppose I should convert date to number to get rid of them. How can I do it isnide a SELECT query?While the comments regarding re-writting the query to allow the possibility of index usage are valid, the warning will still appear even with the re-written query. I am sure that this query would use an index on dt1 if one was available.
SQL>CREATE TABLE t (id number, dt1 date, dt2 date);
Table created.
SQL> CREATE PROCEDURE p1 AS
2 BEGIN
3 FOR r IN (SELECT * FROM t
4 WHERE dt1 = sysdate - 7) LOOP
5 NULL;
6 END LOOP;
7 END;
8 /
SQL>/
SP2-0804: Procedure created with compilation warnings
SQL>show error
Errors for PROCEDURE P1:
LINE/COL ERROR
3/13 PLW-07204: conversion away from column type may result in
sub-optimal query planThe warning in this case is clearly spurious, and the reason is, at the level the compiler is looking, they are different data types. dt1 was inserted as sysdate a few minutes before I did the dunp below.
SQL> SELECT DUMP(dt1) tab_date, DUMP(dt1 - 3) calc_date,
2 DUMP(sysdate) sys_date
3 FROM t;
TAB_DATE CALC_DATE SYS_DATE
Typ=12 Len=7: 120,107,2,27,10,45,42 Typ=13 Len=8: 7,215,2,24,9,44,41,0 Typ=13 Len=8: 7,215,2,27,9,49,13,0A date field in a table is a type 12 while sysdate, and any date that has is a result of a calculation is a type 13. Clearly a "different" datatype.
Practically speaking, in the SQL engine, the type 13 date would be cast to a type 12 date and used in an index probe, but the compiler is likely doing something similar to the DUMP conparision.
I believe that the type 13 dates are a representation of the C time_t struct that Oracle's kernel would likely use internally.
John -
Need Help:Reading Data from RU payroll cluster for table GRREC
Hi...
I need help on how to read data from RU cluster table for table GRREC for the employee & run date and get the value from structure PC292 .
Please let me know about the includes and the import and export statements to be used.
Thanks in advance,
RAVI.Hi,
Here goes pseudocode
Includes:
include: rpppxd00 ,
rpppxd10 ,
rpc2cd09 ,
rpc2rx02_ce , "if ldb pnp_ce is used else use the same include with out _ce
rpc2rx29 ,
rpc2rx39 ,
rpppxm00 ,
rpc2ruu0_ce ,
Declare:
DATA : i_rgdir LIKE pc261 OCCURS 0 WITH HEADER LINE ,
i_result TYPE pay99_result OCCURS 0 WITH HEADER LINE ,
i_grrec LIKE pc292 OCCURS 0 WITH HEADER LINE .
start-of-selection:
GET pernr.
Get the RGDIR VALUE for the current PERNR & selected Molga
get rgdir data TABLES i_rgdir
USING pernr-pernr
p_molga " parameter
CD-KEY-PERNR = PERNR-PERNR.
RP-IMP-C2-CU.
i_rgdir [] = rgdir[].
LOOP AT i_rgdir WHERE fpbeg LE pn-endda
AND fpend GE pn-begda
AND srtza EQ 'A'
AND void NE 'V'.
get_result_tabs TABLES i_result
USING 'RU' " US cluster
pernr-pernr
i_rgdir-seqnr
RX-KEY-PERNR = PERNR-PERNR.
UNPACK i_RGDIR-SEQNR TO RX-KEY-SEQNO.
RP-IMP-C2-RU.
i_grrec[] = i_result-inter-grrec[].
LOOP AT i_grrec.
case i_grrec.
use wage types required here and pass the data to output table.
endcase.
endloop.
endloop
end-of-selction. -
Hi,
I need to print date in the following format:
Jan 21, 2007
11:23 AM 21/01/2007
21-01-2007 18:23
Now as per condition of assignment the year, month, day and hour, min, sec all are entered as separate integer values.
my code:
import java.util.*;
import java.text.*;
public class stringToDate
// Integer value of date and time variables
int day=21;
int month = 1;
int year=07;
int hour=18;
int min=23;
int sec=14;
// Converting integer value into date
public void convertIntoDate()
String strTmp= day+"/"+month+"/"+year+" "+hour+":"+min+":"+sec;
System.out.println("String: " + strTmp);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
try
Date outDate = dateFormat.parse(strTmp);
System.out.println("Converted: " + dateFormat.format(outDate));
catch(Exception e){ System.out.println("Exception: " + e);}
public static void main(String args[]) {
stringToDate dF = new stringToDate();
dF.convertIntoDate();
}Now as per my code i am able to print in the following format:
String: 21/1/7 18:23:14
Converted: 21/01/0007 18:23:14
But if i try to print in other formats it gives me following error message:
Exception: java.text.ParseException: Unparseable date: "21/1/07"
Please help me....vinee wrote:
Hi,
I tried different output format but still i'm facing the same issue
Following the complete code and error message....
import java.util.*;
import java.text.*;
public class stringToDate
// Integer value of date and time variables
int day=21;
int month = 1;
int year=07;
int hour=18;
int min=23;
int sec=14;
// Converting integer value into date
public void convertIntoDate()
DateFormat dateFormat;
Date outDate=null;
String strTmp= day+"/"+month+"/"+year+" "+hour+":"+min+":"+sec;
System.out.println("Entered string for date: " + strTmp);
// Format 01/01/0070 15:24:14
dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
try
outDate = dateFormat.parse(strTmp);
System.out.println("Converted into Date(dd/MM/yyyy HH:mm:ss): " + dateFormat.format(outDate));
catch(Exception e){ System.out.println("Exception in format 1: " + e);}
// Format Jan 21, 2007
dateFormat = new SimpleDateFormat("EEE, MMM d, ''yyyy");
try
outDate = dateFormat.parse(strTmp);
System.out.println("Converted into Date(EEE, MMM d, ''yyyy): " + dateFormat.format(outDate));
catch(Exception fe)
{System.out.println("Exception in format 2: " + fe);}
public static void main(String args[]) {
stringToDate dF = new stringToDate();
dF.convertIntoDate();
}Following is the error message:
Entered string for date: 21/1/7 18:23:14
Converted into Date(dd/MM/yyyy HH:mm:ss): 21/01/0007 18:23:14
Exception in format 2: java.text.ParseException: Unparseable date: "21/1/7 18:23:14"
Now as per the above error message format one is working fine but format 2(// Format Jan 21, 2007) have some issues...kind suggest.
Edited by: vinee on Oct 2, 2008 4:23 AMPlease re-read my last reply.
Once again : see [http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html]
And your:
int year=07; // should be:
int year=2007;
Maybe you are looking for
-
I just purchased the ExportPDF. When I try to convert a pdf document to word online, it gives me an error. What is the problem?
-
Japanese file download problem
Hi I am using Weblogic Server 8.1 I have file upload/download facility in my webapplication. While trying to download file with japanese filename , file name becomes junk The whole code bunch is working fine with weblogic 6.1 Any ideas ?? Regards Imr
-
Help~! - IOexception: Bigger type length than Maximum
Hi all, I've been seeing errors below so often these days when I run my program. Anybody has any clue? "dberror= Error: java.sql.SQLException: Io exception: Bigger type length than Maximum dberror= Error: java.sql.SQLException: Bigger type length tha
-
Replacing a ssd with a sshd?
Can the stock ssd on a new MacBook pro 15.4" with retina be replaced with a hybrid ssd (Sshd)? I want upgrade mine. Also if it can will it void the warranty? THanks for the help!
-
Document sizes and jpeg compression / quality
In relation to Photoshop, in the status bar at the bottom it displays what it calls "document sizes". Would someone be able to clarify can this be used to determin the quality of a jpeg file ? For example if I open up a jpeg with no compression (fil