Date validation- need help
Hi, I am trying to validate my date input from the front end which has to be in mm/dd/yyyy format only...I am unsing the code as shown below
DateFormat dateFormatter = new SimpleDateFormat("mm/dd/yyyy");
convertedValue = dateFormatter.parse(fieldValue);
break;
but this is not working..any format is being accepted :(
nn12 wrote:
I tried this
class Test1 {
public static void main(String[] args) {
Object convertedValue = null;
DateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
try {
convertedValue = dateFormatter.parse("13/12/2008");
System.out.println(convertedValue);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
But it didnt help :(This works! the Date parsed will be: 12. jan 2009!
Similar Messages
-
Workflow Validation - Need Help
I'm fairly new to video editing. Everything below I figured out through trial and error until I found a sequence that seems to work well. I just want to know if it's the best I can make it. Storage space is a non-issue. I have no intention of burning to DVD. I'm not interested in sound settings right now. All of the videos sound good enough. I'll mess with that once I've got this workflow tweaked.
I want the following three files at the end of my projects.
1) HD Quality MP4 files that I can play on a PC or PS3. I chose MP4 because that's the only format so far that I've found that the PS3 plays. I'm open for recommendations. These should always be deinterlaced.
2) Good Quality MP4 files that I can post on my webserver for relatives to download and watch.
3) The best master copy I can get from FCE for future edits. Is this a good idea?
My Hardware/Software:
Television - 1080p 65" JVC
Mac - Macbook Pro 17" C2D 2.5g / 4g Ram
FCE 4.0.1
Toast Titanium 9
Camcorder: HG10 1920x1440 60i (Most of my filming is of kids running around. Open for discussion on 24p?) I've been archiving M2TS files from this camcorder for a year. I do not have the original file structure for my archived footage, just the M2TS files. In the future I can import direct to FCE (Tested it and it works fine), but I like the idea of having my source M2TS files with 5.1 sound in-tact.
MediaInfo 0.7.7.58
Step 1: Use Toast 9 to convert M2TS to .MOV for import into FCE. MediaInfo on source M2TS Files:
General / Container Stream # 1
Total Video Streams for this File -> 1
Total Audio Streams for this File -> 1
Video Codecs Used -> AVC
Audio Codecs Used -> AC3
File Format -> BDAV
Play Time -> 19s 170ms
Total File Size -> 35.4 MiB
Total Stream BitRate -> 15.5 Mbps
Video Stream # 1
Codec (Human Name) -> AVC
Codec Profile -> [email protected]
Frame Width -> 1 440 pixels
Frame Height -> 1 080 pixels
Frame Rate -> 29.970 fps
Total Frames -> 575
Display Aspect Ratio -> 16/9
Scan Type -> Interlaced
Scan Order -> TFF
Colorimetry -> 4:2:0
Codec Settings (Summary) -> CABAC / 2 Ref Frames
Codec Settings (CABAC) -> Yes
Video Stream Length -> 19s 166ms
Video Stream BitRate -> 14.6 Mbps
Bit Depth -> 24 bits
Toast Conversion Settings:
Device QT Movie
Quality Custom
Compression AIC
Frame Rate 29.97
Key Frames All (I don't understand Key Frames)
Compressor HDV1080i
Interlaced is checked/greyed
Size HD1440x1080 16:9
Preserve = No
DeInterlace = No
MediaInfo on Toast AIC Export:
General / Container Stream # 1
Total Video Streams for this File -> 1
Total Audio Streams for this File -> 1
Video Codecs Used -> icod
Audio Codecs Used -> AAC LC
File Format -> QuickTime
Play Time -> 19s 63ms
Total File Size -> 240 MiB <------I guess I can delete these AIC files when my FCE project is done right?
Total Stream BitRate -> 105 Mbps
Title (Tag) -> 00071
Video Stream # 1
Codec (Human Name) -> icod
Codec (FourCC) -> icod
Frame Width -> 1 440 pixels
Frame Height -> 1 080 pixels
Frame Rate -> 29.970 fps
Total Frames -> 570
Display Aspect Ratio -> 4/3
QF (like Gordian Knot) -> 2.264
Video Stream Length -> 19s 19ms
Video Stream BitRate -> 106 Mbps
Video Stream BitRate Mode -> VBR
Video Stream Size -> 239 MiB (100%)
Date of Original Encoding -> UTC 2008-11-07 02:04:14
Step 2: Import to FCE
Select Sequence Preset - Apple Intermediate Codec 1920x1080i60
When I drop the clip on the timeline, I get:
"For best performance your sequence and External Video should be set to the format of the clips you are editing. Change sequence settings to match the clip settings?" - NO
edit FCE project and render
Step 3: Export to MP4 for PC and PS3 Playback
Export -> QT Conversion -> -Options
File Format - MP4
Video Format h.264
Data Rate 8000kb/s (Is this the best option?)
Image Size 1280x720HD (1920x1080 looks interlaced?)
Frame Rate 29.97 (Defaults to 30. Why?)
Key Frame Every 24 frames. (Why?)
Video Options
Restrict Profiles to Main (ipod?)
Encoding (Assume best quality is what I want? Why?)
Media Info on FCE MP4 Export:
General / Container Stream # 1
Total Video Streams for this File -> 1
Total Audio Streams for this File -> 1
Video Codecs Used -> AVC
Audio Codecs Used -> AAC LC
File Format -> MPEG-4
Play Time -> 19s 342ms
Total File Size -> 18.7 MiB
Total Stream BitRate -> 8 094 Kbps
Video Stream # 1
Codec (Human Name) -> AVC
Codec (FourCC) -> avc1
Codec Profile -> [email protected]
Frame Width -> 1 280 pixels
Frame Height -> 720 pixels
Frame Rate -> 29.970 fps
Total Frames -> 579
Display Aspect Ratio -> 16/9
Scan Type -> Progressive
Colorimetry -> 4:2:0
Codec Settings (Summary) -> 2 Ref Frames
QF (like Gordian Knot) -> 0.289
Codec Settings (CABAC) -> No
Video Stream Length -> 19s 319ms
Video Stream BitRate -> 7 973 Kbps
Video Stream BitRate Mode -> VBR
Bit Depth -> 24 bits
Video Stream Size -> 18.4 MiB (98%)
Video Stream Language -> English
Date of Original Encoding -> UTC 2008-11-07 02:18:44
Step 4: Export FCE to MP4 for Web Use:
Don't have this sorted out yet, but I reckon I'll use the QT Conversion with h.264, 640x480 or something slightly smaller with Preserve Aspect Ratio/Letterbox/Deinterlace
I know there are a ton of details here. If more is needed, please let me know.
Thanks for the help,
JohnOK, I'll bite. I don't understand the point of Step 1 - Use Toast to convert from .M2TS to .MOV.
I could certainly be missing something, but M2TS and MOV are container formats. So you are really doing two things: converting the video/audio from AVC/AAC in an M2TS container to something FCE can edit, namely AIC in an MOV container. I don't understand this step. FCE's log and transfer does this exact same thing (convert AVCHD to AIC), except without the external software. So, why use Toast if FCE already does this? You can also add metadata to the clips as they are imported so you can make heads or tails of them later.
I'm still learning too. So I hope this reads as a question
-Nick
Message was edited by: Nick Pope -
Hello
I am creating a travel form on adobe designer 7.0 for employees to fill out before they go on vacation. So i wrote a script that makes sure the the date entered for DateFrom is >= the current date and the DateTo is >= DateFrom. I have been told to make the date format MM/DD/YY but for some reason the script only works when the format is MM/DD/YYYY.
Here is my script For DateFrom:
if (Date() < Date2Num($.formattedValue, "MM/DD/YYYY"))
then
xfa.host.setFocus("xfa.form.form1.DateTo")
else
xfa.host.setFocus("xfa.form.form1.DateFrom")
xfa.host.messageBox("Your requested date can NOT come before the current date","Warning.",1)
endif
and the script for DateTo:
if (Date2Num($.formattedValue, "MM/DD/YYYY") >= Date2Num(xfa.form.form1.DateFrom.formattedValue, "MM/DD/YYYY"))
then
xfa.host.setFocus("xfa.form.form1.enterC")
else
xfa.host.messageBox("The 'TO' Date must come after the 'FROM' Date", "TO DATE ERROR")
xfa.host.setFocus("xfa.form.form1.DateTo")
endif
enterC is the next focus object after DateTo
I have tried the obvious by switching the formattedValue to "MM/DD/YY" but with no success. I have also tried switching the Display Pattern, Validation Pattern, and the Data Pattern to "MM/DD/YY" but nothing seems to work. Does anyone know how to make this work with MM/DD/YY?
Thanks in advance for any help
NickIrrespective of the display pattern/format I would use the following FormCalc code in your situation. Also check the attachment.
'exit' event of the DateFrom:
if (Date() <= Date2Num($.rawValue, "YYYY-MM-DD")) then
//xfa.host.setFocus("xfa.form.form1.DateTo")
var v1
v1=1
else
xfa.host.setFocus("xfa.form.form1.DateFrom")
xfa.host.messageBox("Your requested date can NOT come before the current date","Warning.",1)
endif
'exit' event of the DateTo
if (Date2Num($.rawValue, "YYYY-MM-DD") > Date2Num(xfa.form.form1.DateFrom.rawValue, "YYYY-MM-DD")) then
//xfa.host.setFocus("xfa.form.form1.enterC")
var v1
v1 =1
else
xfa.host.messageBox("The 'TO' Date must come after the 'FROM' Date", "TO DATE ERROR")
xfa.host.setFocus("xfa.form.form1.DateTo")
endif -
Hi ,
my data's date(DATA_ENTRY_TIME) is --> 7/29/2006 4:02:02 AM
ques1 :
when i run this query --> select TO_DATE(DATA_ENTRY_TIME , 'dd-mon-rr HH.MI.SS AM' ) FROM LOT_HISTORY_2DCHRT
result : 7/29/2006
shldn't it return the time as well ?
ques 2 :
i have a insert query from a selection of such criteria so as to be the same format as the DATA_ENTRY_TIME
-->
WHERE DATA_ENTRY_TIME >= TO_CHAR(TRUNC(SYSDATE - 6 / 24) , 'MM/DD/YYYY HH:MI:SS AM')
AND DATA_ENTRY_TIME<= TO_CHAR(TRUNC(SYSDATE) , 'MM/DD/YYYY HH:MI:SS AM')
and i got the error while running it
ORA-01843: not a valid month
ORA-02063: preceding line from PLL2
what is wrong here actually ?
ques 3
select * from nls_session_parameters
where parameter in ('NLS_DATE_FORMAT' , 'NLS_TIME_FORMAT') ;
these are the values
DD-MON-RR & HH.MI.SSXFF AM
do i need to an alter session in order for ques 2 to work ??
ques 4
if both field are of date type but different format e.g field1 is 'dd/mm/yyyy hh:mi:ss am' and field2 is 'mon-dd-yyyy hh:mi:ss am'
can comparision such as field1 >= field2 still be done ?
ques 5
if i use to_char for both field1 & field2 in ques 4 , can a comparison be done and is it accurate as it's now a string(if i am correct) ?
tks & rdgsmy data's date(DATA_ENTRY_TIME) is --> 7/29/2006
4:02:02 AM
ques1 :
when i run this query --> select
TO_DATE(DATA_ENTRY_TIME , 'dd-mon-rr HH.MI.SS AM' )
FROM LOT_HISTORY_2DCHRT
result : 7/29/2006
shldn't it return the time as well ?What you see depends on the settings you have for displaying the data. You can change your default date format settings as follows:
SQL> select sysdate from dual;
SYSDATE
08/02/2006
SQL> alter session set nls_date_format='mm/dd/yyyy hh24:mi:ss';
Session altered.
SQL> select sysdate from dual;
SYSDATE
08/02/2006 08:08:44
SQL>Or you can muck about with converting the dates into varchars if that's what you really want, but then if you need to do further date functionality against them you have to ensure you convert them correctly back to date format. I'd suggest that you just work with dates as oracle designed them to be and only convert to varchar (using TO_CHAR) when you really really need to.
ques 4
if both field are of date type but different format
e.g field1 is 'dd/mm/yyyy hh:mi:ss am' and field2 is
'mon-dd-yyyy hh:mi:ss am'
can comparision such as field1 >= field2 still be
done ?Internally the date types are stored identically. The formatting only comes into play when dates are displayed or converted to varchar so yes, if they are both stored on the database as DATE types then you can just do a straight comparison. I'm not sure how you are determining that they are "different format" unless you are querying them in different environments.
>
ques 5
if i use to_char for both field1 & field2 in ques 4 ,
can a comparison be done and is it accurate as it's
now a string(if i am correct) ?If you convert to a varchar then you are doing a string comparison which works fine if you are doing "=", but if you are intending to do ">=" then you'll likely get some unexpected results
SQL> select 'greater'
2 from dual
3 where to_date('08/02/2006 08:00:00', 'mm/dd/yyyy hh24:mi:ss') >= to_date('08/10/2005 08:00:00', 'mm/dd/yyyy hh24:mi:ss');
'GREATE
greater
SQL> ed
Wrote file afiedt.buf
1 select 'greater'
2 from dual
3* where '08/02/2006 08:00:00' >= '08/10/2005 08:00:00'
SQL> /
no rows selected
SQL>The second comparison using varchar doesn't work because the 4th character in the right hand string ("1") is greater than the 4th character in the left hand string ("0"). It is literally a chr for chr comparison rather than treating the whole string as a value in its own right which is what you get with dates.
For simplicity's sake, think of dates as being stored on the database as the number of seconds since a fixed date in time. As they are purely stored as a number internally it's easy for the database to compare them. The moment you conver things to varchar you just get yourself in a mess.
;) -
Hi experts,
I have included the sql for the data as it is in the table and the format in which I am trying to display the data but would need your help. Many Thanks.
create table #DATA
(CustNum int,
weeknumber int,
tserial int,
code varchar(2),
amount money,
Bal money)
insert into #DATA values ( 100, 40 ,12, 'C', 13.60, 87.37)
insert into #DATA values ( 100, 41 ,15, 'D', 85.92, 73.77)
insert into #DATA values ( 100, 42 ,24, 'C' ,13.60, 159.69)
insert into #DATA values ( 100, 43 ,35, 'C',142.74, 146.09)
insert into #DATA values ( 100, 44 ,47, 'D', 85.92,3.35)
insert into #DATA values ( 100, 45, 55,'C',15.00,89.27)
select * from #DATA ORDER BY weeknumber desc
create table #Req_output
( CustNum int,
WeekNumber int,
Debit money,
Credit money,
Balance money
insert into #Req_output values(100, 45, Null, 15, 74.27)
insert into #Req_output values(100, 44, 85.92,Null, 89.27)
insert into #Req_output values(100, 43, Null,142.74,3.35)
insert into #Req_output values(100, 42, Null,13.60, 159.69)
insert into #Req_output values(100, 41, 85.92, Null,159.69)
insert into #Req_output values(100, 40, Null,13.60, 73.77)
select * from #Req_output
drop table #DATA
drop table #Req_output
Let me know if I have missed any details from the query above.
Thanks again !Having such a balance column is not a good idea.
DECLARE @Improved TABLE
CustNum INT ,
weeknumber INT ,
tserial INT ,
code VARCHAR(2) ,
amount MONEY
INSERT INTO @Improved
VALUES ( 100, 1, 1, 'B', 87.37 ),
( 100, 40, 12, 'C', -13.60 ),
( 100, 41, 15, 'D', 85.92 ),
( 100, 42, 24, 'C', -13.60 ),
( 100, 43, 35, 'C', -142.74 ),
( 100, 44, 47, 'D', 85.92 ),
( 100, 45, 55, 'C', -15.00 );
SELECT * ,
SUM(amount) OVER ( ORDER BY tserial ASC ) AS ActualBalance
FROM @Improved
ORDER BY weeknumber DESC;
WITH Data
AS ( SELECT * ,
SUM(amount) OVER ( ORDER BY tserial ASC ) AS ActualBalance
FROM @Improved
SELECT D.CustNum ,
D.weeknumber ,
D.tserial ,
IIF(code = 'C', D.amount, NULL) AS Credit ,
IIF(code = 'D', D.amount, NULL) AS Debit ,
D.ActualBalance
FROM Data D
WHERE code != 'B'
ORDER BY D.weeknumber DESC ,
D.tserial DESC; -
I'm trying to do a FFT using I and Q Data, I need help.
I’m collecting data on an Agilent 89600 VSA, and storing it
to a file, it stores the data in I and Q format (real and imaginary) in 2 columns. Can read the data then using “Re/Im to
complex” (math function) I go to the “FFT.vi”.
After that is done how do I get it scaled and display it on a graph? Everything I have tried has not worked. If anyone can help please do.
LabVIEW 7.1, Windows XP
Thank you
BobHi, Bob.
This KnowledgeBase discusses how to display complex numbers in a graph. Let me know if this doesn't answer your question.
Have a nice afternoon!
Sarah K.
Search PME
National Instruments -
Infoset data issues need help ASAP
Hello BW experts,
I have created an InfoSet, to read data from one Single ODS. The ODS has already data active, but the Query on infoset doesnt returns any data.also i checked in listcube `without any success.
Could you please advise me where it might be wrong. i didn't changed anything in infoset. Just created a Infoset on top of ODS.
I tried all the options and made sure that it's not authorization issue.i deleted the ods data and loaded some test data and tried to create a query on ods it's fetching the data but no data pulling by infoset.
something wrong inbetween infoset and ods. could you please advise me what might be wrong and how can i resolve.
might be some issues with the generated program or some issue with the database level.
some of the infosets i created fectching partial data , some are getting full data from ODS and some of the infosets not at all picking the data. Overall i have created about 80 Infosets.
We are in BW 3.5. Recently upgraded the patch successfully.
Looking forward for your precious advise.
Thanks,
Naveen Reddyjust tried to go through it again, and it was close to finishing, less than a 1/2 hour left. and it got the error: "the installer is experiencing errors installing onto "Macintosh HD". The disk may be damaged, please try installing on another disk."
does that mean i'm going to have to buy a new internal hard-drive? once again any advice will be really helpful. Thanks
p.s. I also went and verified the disk again and it said there wasn't any issues with it. and i repaired it anyways and it said it was fine. This is super annoying
Message was edited by: Doonyal -
there is a cool date picker i downloaded from http://www.kodart.com, it looks good and easy to handle,
but i would like to add some feautes like pop-up comments for dates, change size of the picker and so on.
there is something a source code on their site, but i couldn't get it.
i would really appreciate help from anyone. please write to [email protected] or reply to topic. all the information on http://www.kodart.com
thanks in advanceThat doesnt appear to be a java applet, or class for that matter. Its PHP and JavaScript combined.
J -
I am new to Core Data, so pleases forgive my ignorance. Here is what I am trying to do:
I have two entities in my data model, one that represents a college course and one which represents a homework assignment. I want to have one of the attributes of my assignment entity be a course entity, so that I can setup my UI to display attributes of a course when a user selects an assignment to which that course is associated. How can I do this?
Again, please forgive me if I am being too vague. Let me know if I need to clarify or post additional information.That link opens to a MySpace page that requires a password, so your image can't be viewed. It's not a good idea to link an image to your MySpace page anyway. Upload your image to a free image host like PhotoBucket or Flickr (or any host) and link to that.
If you are working on the background, I hope you are working on a copy of the image or at least retaining the original image layer without modification. Editing can be tricky enough, but editing away bad editing is worse. -
Date issue, need help on this one.
Can anyone show me the proper ways of how to update the SQL date type?
I can't insert records into table because of the "date" problem.
Thanks in advance.
Yee Hiong.
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class Personal extends JFrame{
inpPanel1 inputPanel;
btnPanel1 buttonPanel;
dtPersonal data;
Date dobDate, djDate; // this one... causes problems.
String uri;
Connection conn;
Statement stmtAppendTable;
ResultSet rs;
public Personal(){
super ("Personal");
Container c = getContentPane();
c.setLayout(new BorderLayout());
inputPanel = new inpPanel1();
buttonPanel = new btnPanel1();
buttonPanel.btnSave.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae) {
openDataBase();
appendRecord();
closeDataBase();
c.add(inputPanel, BorderLayout.CENTER);
c.add(buttonPanel, BorderLayout.SOUTH);
pack();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public void openDataBase() {
uri = "jdbc:odbc:MABA";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch (ClassNotFoundException cnfex) {
System.out.println(cnfex.getMessage());
try {
conn = DriverManager.getConnection(uri);
stmtAppendTable = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmtAppendTable.executeQuery("SELECT * FROM Personal");
}catch(SQLException sqlex) {
System.out.println(sqlex.getMessage());
public void appendRecord() {
data = new dtPersonal();
data.setID(Integer.parseInt(inputPanel.tfPersonalID.getText()));
data.setName(inputPanel.tfName.getText());
if(inputPanel.rbMale.isSelected()) {data.setSex("M");}
else
if(inputPanel.rbFemale.isSelected())
{data.setSex("F");}
data.setAddress1(inputPanel.tfAddress1.getText());
data.setAddress2(inputPanel.tfAddress2.getText());
data.setAddress3(inputPanel.tfAddress3.getText());
data.setCity(inputPanel.tfTownCity.getText());
data.setState(inputPanel.cboState.getSelectedItem().toString());
data.setContactPhone(inputPanel.tfContactPhone.getText());
data.setHeight(Double.parseDouble(inputPanel.tfHeight.getText()));
data.setWeight(Double.parseDouble(inputPanel.tfWeight.getText()));
data.setStatus(inputPanel.tfStatus.getText());
data.setDateOfBirth(inputPanel.tfDateOfBirth.getText());
data.setDateJoined(inputPanel.tfDateJoin.getText());
dobDate = Date.valueOf(data.getDateOfBirth());
djDate = Date.valueOf(data.getDateJoined());
try {
rs.moveToInsertRow();
rs.updateInt("Personal_ID", data.getID());
rs.updateString("Name", data.getName());
rs.updateString("Sex", data.getSex());
rs.updateString("Address1", data.getAddress1());
rs.updateString("Address2", data.getAddress2());
rs.updateString("Address3", data.getAddress3());
rs.updateString("State", data.getState());
rs.updateString("Town", data.getCity());
rs.updateString("Contact", data.getContactPhone());
rs.updateDouble("Height", data.getHeight());
rs.updateDouble("Weight", data.getWeight());
rs.updateDate("Date_of_Birth", dobDate);
rs.updateDate("Date_Joined", djDate);
rs.updateString("Status", data.getStatus());
rs.insertRow();
System.out.println("Data Insert Successful");
}catch(SQLException sqlex) {
System.out.println(sqlex.getMessage());
public void closeDataBase() {
try {
rs.close();
stmtAppendTable.close();
conn.close();
}catch(SQLException sqlex) {
System.out.println(sqlex.getMessage());
public static void main(String args[]){
new Personal();
}It crashes when I insert a record to Access's database. I remove the date data type then it runs fine. How to solve this date problem?
-
Comparing dates problem, need help?
the checks are not working correctly, and I am missing something. Code is below.
for the start date check.
1. if I put in 28-OCT-2006, I get my error message. Why wont it let me enter today and how do I fix it?
2. If the start and stop date are the same, my SAVE button code fires. WHy? and then it still ends up commiting.
thanks,
HERE IS THE START DATE TEXT
SET_ITEM_PROPERTY('DRUG_ID', Enabled, PROPERTY_FALSE);
declare
alert_NO varchar2(10);
startDate date;
systemDate date;
begin
startDate := :DRUG_PRICE.START_DATE;
systemDate := sysDATE;
--this displays at the buttom of form
-- MESSAGE('StartDate Must be >= Today');
if(startDate < systemDate ) then
--this displays at the buttom of form
MESSAGE('StartDate Must be >= Today');
--calls the appropriate alert
alert_NO := show_alert('STARTSYS');
RAISE FORM_TRIGGER_FAILURE;
end if;
end;
HERE IS MY SAVE BUTTON
declare
alert_NO varchar2(10);
startDate date;
stopDate date;
begin
startDate := :DRUG_PRICE.START_DATE;
stopDate := :DRUG_PRICE.STOP_DATE;
--this displays at the buttom of form
MESSAGE('Error with the Dates');
if(startDate > stopDate ) then
-- calls the appropriate alert
alert_NO := show_alert('START');
RAISE FORM_TRIGGER_FAILURE;
elsif (startDate <= stopDate) then
MESSAGE('Drug Price Added Successfully.');
commit;
end if;
end;Is this forms?
Anyway, regarding your question, you're comparing the input date against sysdate and maybe you're sending a trunc date so sysdate is always bigger (it includes day, month,year, hour, minute and seconds). Since you're sending a truncate date you're comparing now against today 12:00:00 a.m.
Ex:
select sysdate from dual;
SYSDATE
28.10.06 23:31
select case when to_Date('28/10/2006', 'dd/mm/yyyy')<sysdate then 'a' else 'b' end FROM DUAL;
CAS
a -
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 in formatting the Date - Date does not
Need help in formatting the Date - Date does not formats and give Not a valid month error in the below scenario.
select oc.ST_PGM_MGR, r.ag_dnum, get_major_work_type(r.perf_eval_rtng_id) "v_work_code", r.ag_dnum_supp "supp", r.intfinal, to_char(r.formdate,'MM/DD/YYYY') "formdate", to_char(r.servfrom,'MM/DD/YYYY') "srv_from", to_char(r.servto,'MM/DD/YYYY') "srv_to", descript, add_months(to_char
--- Bellow line of Code on trying to format it to mm/dd/yyyy gives the error
(r.formdate, 'DD-MON-YYYY'),12) "formdate2"
from table REdited by: Lucy Discover on Jul 7, 2011 11:34 AM
Edited by: Lucy Discover on Jul 7, 2011 1:05 PMYour syntax is wrong - look at the post above where this syntax is given:
to_char (add_months(r.formdate,12), 'MM/DD/YYYY') "formdate2"Look at the formula from a logical perspective - "inside out" to read what is happening -
take formdate, add 12 months
add_months(r.formdate, 12)then apply the to_char format mask - basic syntax
to_char(date, 'MM/DD/YYYY')Compare to your syntax:
to_char(add_months(r.formdate, 'MM/DD/YYYY'),12) "formdate2"You will see your format string inside the call to add_months, and your 12 inside the call to to_char.
Good luck! -
Help with date validation on input boxes.
I need some help with date validation on input boxes.
What I�m trying to create is a form where a user inputs dates and then the rest of the form calculates the other dates for them.
i.e. � A user inputs 2 dates (A & B) and then a 3rd date which is 11 weeks before date B is calculated automatically.
Is this possible and if so how do I do it ???
ThanksHi,
to get third date try this:
java.util.Date bDate = ...;
Calendar yourCalendar = new GregorianCalendar();
yourCalendar.setTime(bDate);
yourCalendar.roll(Calendar.WEEK_OF_YEAR, -11);
java.util.Date cDate = yourCalendar.getTime();Regards
Ldinka -
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
Maybe you are looking for
-
HP Officejet Pro 8610 - Tray 2
I've just purchased an HP Officejet Pro 8610 with an A8Z70A 2nd tray. The 2nd tray is recognized on the the printer but not on the software. I am using the 2nd tray for legal size plain paper. I have updated firmware & drivers. Not fixed. What do I n
-
I understand that this is helpful for those that have limited data each month, but for me, and I'm sure everyone else who has unlimited data, this is just a nuisance and rather frustrating. I'm in the Air Force and where I am right now I have zero ac
-
HT4859 How to get the photos and videos backed up on iCloud to import.
I had not sync my phone prior to them replacing my phone but the Mac Genius said I was not going to lose any of the stuff on my phone because I had used iCloud. I was able to successfully back up all my files but am unable to import the new photos a
-
Requested delivery date not copied from quote item to order item
CRM 7.0 copying from a quote to an order is ot copying the requested date at the item or header. For the Header we are using copying routine SLSHDR and for the item SALES There is a date profile assigned to both the quote & item category, these obje
-
Alternative to FM 'CRM_BUPA_SELECT_BP_SALES_AREAS'
Within the ON_SAVE method of BP_HEAD/Overview I am retrieving the Sales areas for the current Account using FM CRM_BUPA_SELECT_BP_SALES_AREAS. However, when I enter Sales area data for the first time this FM is not returning any data. This is probabl