Results 1 to 4 of 4
Thread: I need help with JOption Panel!
- 01-26-2012, 02:59 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
I need help with JOption Panel!
Write a program that reads a string for a date in the format month / day / year and displays it
in the format day . month . year, which is a typical format used in Europe. For example, if the
input is 06/17/08, the output should be 17.06.08. Your program should use JOptionPane for
input and output.
Note - Your program should create an output string from the input string and should include
the following lines with appropriate Java statements at “…”
__________________________________________________ ___
import javax.swing.JOptionPane;
public class DateDisplayer
{
public static void main(String[] args)
{
String dateString = JOptionPane.showInputDialog(
"Enter a date in the format month/day/year .\n" +
"I will output the date in the format
day.month.year\n");
String day, month, year;
dateString = dateString.trim();
int delimiter = dateString.indexOf("/");
month = dateString.substring(…);
…
//System.out.println("index is " + delimiter);
//System.out.println("Month is " + month);
…
String rest = dateString.substring(…).trim();
//System.out.println("Rest is " + rest);
…
delimiter = rest.indexOf("/");
day = rest.substring(…);
…
//System.out.println("index is " + delimiter);
//System.out.println("day is " + day);
…
year = rest.substring(…).trim();
//System.out.println("year is " + year);
…
JOptionPane.showMessageDialog(null, dateString +
" converts to: " + day + "." + month + "." + year);
System.exit(0);
}
}
-
Re: I need help with JOption Panel!
So...
what exactly is your question? Details are very important.
- 01-26-2012, 03:58 AM #3
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
-
Re: I need help with JOption Panel!
Similar Threads
-
Region and Language problem in Joption
By rjain in forum New To JavaReplies: 0Last Post: 11-04-2011, 11:19 AM -
Can someone give a sample for JOption with 2 strings?
By RanLineR in forum New To JavaReplies: 12Last Post: 10-22-2010, 07:52 AM -
Example of JOption
By RanLineR in forum New To JavaReplies: 4Last Post: 10-20-2010, 12:27 PM -
JOption pop up window is behind all other windows
By biggmann in forum New To JavaReplies: 3Last Post: 10-15-2010, 08:24 PM -
JOption Msgbox title help?
By ZaabZ in forum New To JavaReplies: 7Last Post: 08-26-2010, 09:12 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks