× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I would think you should be able to use the SimpleDateFormat then to format
the date.

Probably not the most elegant, but...

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Scanner;
import java.text.SimpleDateFormat;

public class TestStringDate {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
int month = 0;
int day = 0;
int year = 0;
String stringDate = "11/4/2008";
Scanner scanner = new Scanner(stringDate);
scanner.useDelimiter("/");
int part = 0;
while (scanner.hasNext()) {
part++;
if (part > 3)
break;
if (scanner.hasNextInt()) {
switch (part) {
case 1:
month = scanner.nextInt() - 1;
break;
case 2:
day = scanner.nextInt();
break;
case 3:
year = scanner.nextInt();
break;
}
continue;
}
}

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Calendar cal = new GregorianCalendar(year, month, day);
String s = sdf.format(cal.getTime());
System.out.println(s);
}

}


This will at least give you a string in the format you need.

James R. Perkins


On Wed, Nov 5, 2008 at 2:36 PM, <TAllen@xxxxxxxxxxxx> wrote:

I agree (again) that using strings is not ideal. Your guess is more or
less accurate. I'm using a set of classes for database access that does
not currently provide for SQL date objects.

Thanks,
Todd

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.