This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

date parse error


Notice contentlength and date difference jdk <-> libgcj

output from jdk 1.3.1 - linux
__start out
Content Type: text/html
  Content Encoding: null
  Content Length: 17328
  Date: Fri Sep 28 15:57:23 CEST 2001
  Parsed date: 2001-09-28 15:57:23
  Last Modified: Thu Jan 01 01:00:00 CET 1970
  Expiration: Thu Jan 01 01:00:00 CET 1970
  Request Method: GET
  Response Message: OK
  Response Code: 200
__end out

output from binary (gcj -Wall -g3 -o GetURLInfo --main=GetURLInfo
GetURLInfo.java )
gcj version = 3.0.2 Debian
__start out
  Content Type: text/html
  Content Encoding: null
  Content Length: -1
  Date: Fri Sep 28 14:12:36 GMT+00:00 2001
  Parsed date: 2001-09-28 12:12:36
  Last Modified: Thu Jan 01 01:00:00 GMT-01:00 1970
  Expiration: Thu Jan 01 01:00:00 GMT-01:00 1970
  Request Method: GET
  Response Message: OK
  Response Code: 200
__end out


--
Niklas Fondberg
niklas.fondberg@i3micro.com
System Developer I3 Micro Technology
Sweden
---------------------  CODE FOLLOWS --------
/*
 * Copyright (c) 2000 David Flanagan.  All rights reserved.
 * This code is from the book Java Examples in a Nutshell, 2nd Edition.
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or
implied.
 * You may study, use, and modify it for any non-commercial purpose.
 * You may distribute it non-commercially as long as you retain this
notice.
 * For a commercial use license, or to purchase the book (recommended),
 * visit http://www.davidflanagan.com/javaexamples2.
 *
 *
 *
 *  Fri, 28 Sep 2001 08:04:43 GMT // telnet
 *  Fri Sep 28 10:20:00 CEST 2001 // this new Date(c.getDate())
 */
import java.net.*;
import java.io.*;
import java.util.Date;
import java.text.*;

/**
 * A class that displays information about a URL.
 **/
public class GetURLInfo {
    /** Use the URLConnection class to get info about the URL */
    public static void printinfo(URL url) throws IOException {
 DateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        URLConnection c = url.openConnection();  // Get URLConnection
from URL
 c.connect();                             // Open a connection to URL

 c.setUseCaches(false);

        // Display some information about the URL contents
        System.out.println("  Content Type: " + c.getContentType());
        System.out.println("  Content Encoding: " +
c.getContentEncoding());
        System.out.println("  Content Length: " + c.getContentLength());

        System.out.println("  Date: " + new Date(c.getDate()));
 System.out.println("  Parsed date: "+ myFormat.format( new
Date(c.getDate()) ));
        System.out.println("  Last Modified: " +new
Date(c.getLastModified()));
        System.out.println("  Expiration: " + new
Date(c.getExpiration()));

        // If it is an HTTP connection, display some additional
information.
        if (c instanceof HttpURLConnection) {
            HttpURLConnection h = (HttpURLConnection) c;
            System.out.println("  Request Method: " +
h.getRequestMethod());
            System.out.println("  Response Message: "
+h.getResponseMessage());
            System.out.println("  Response Code: " +
h.getResponseCode());
        }
    }

    /** Create a URL, call printinfo() to display information about it.
*/
    public static void main(String[] args) {
        try { printinfo(new URL(args[0])); }
        catch (Exception e) {
            System.err.println(e);
            System.err.println("Usage: java GetURLInfo <url>");
        }
    }
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]