Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7699525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:29:57+00:00 2026-05-31T22:29:57+00:00

I’m a beginner in Java and I’m writing a program to read from multiple

  • 0

I’m a beginner in Java and I’m writing a program to read from multiple text files which have data that looks like:

[C417] ComputerName:KCUTSHALL-PC UserID:GO kcutshall Station 9900
(locked) LanId: | (11/23 10:54:09 – 11/23 10:54:44) | Average limit
(300) exceeded while pinging http://www.google.com [74.125.224.147] 8x

I need to enter date range from the user and check if the entered date lies between the date range in the files and display the computer name corresponding to the dates.

How should I go about it?

I tried parsing the date with SimpledDateFormat but it gives an exception:

Unparsable date (11/23 10:54:09 – 11/23 10:54:44)

Here is the code I wrote:

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.Scanner;
import java.util.*;
import java.text.*;

public class test {
  public static void main(String args[]) throws ParseException {
    try {
   Scanner input1=new Scanner(System.in);

   Scanner input2=new Scanner(System.in);
   System.out.println("Enter start date");
    String userDate1=input1.nextLine();
    System.out.println("Enter end date");
     String userDate2=input2.nextLine();
      //DateFormat df = new SimpleDateFormat ("yyyy-MM-dd");
DateFormat df = new SimpleDateFormat ("MM/dd");
      Date d1=df.parse(userDate1);
      Date d2=df.parse(userDate2);

      ZipFile zf=new ZipFile("C:\\Users\\Engineeir\\Desktop\\QoS_logs.zip");
      Enumeration entries=zf.entries();

      BufferedReader input=new BufferedReader(new InputStreamReader(
          System.in));
      while (entries.hasMoreElements()) {
        ZipEntry ze=(ZipEntry) entries.nextElement();

     BufferedReader br=new BufferedReader(new InputStreamReader(zf.getInputStream(ze)));
        String line;
        while ((line=br.readLine())!=null) {
              String[] st=line.split("\\|",-1);

              if(st.length>1)
             {
            String name=st[0];
            String dates=st[1];
DateFormat df1 = new SimpleDateFormat (" '('MM/dd '-' ')' ");
//String d3 = (Date)df1.parse(dates);
//SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd");
//Date d4 = newFormat.format(d3);
  //Date theDate = dateFormat.parse(d4); 

            Date d3=df1.parse(dates);

       if((d1.compareTo(d3)*d3.compareTo(d2))>0){
           System.out.println(name); }
else{
    System.out.println("Out of Range..Not found");
     }       
 }
           // br.close();



 }  } }catch (IOException e) {
      e.printStackTrace();
    }

}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:29:58+00:00Added an answer on May 31, 2026 at 10:29 pm

    Here, this might give you a mind

        public static String dates = "11/23 10:54:09 - 11/23 10:54:44";
            public static Pattern pattern = Pattern.compile("\\d\\d\\/\\d\\d \\d\\d:\\d\\d:\\d\\d");
    
            public boolean isDateOk() throws Exception {
                Matcher m = pattern.matcher(dates);
                SimpleDateFormat format = new SimpleDateFormat("MM/dd HH:mm:ss");
                Date startDate = null;
                Date endDate = null;
                Date ourDate = new Date();
                if(m.find()){
                    startDate = format.parse(m.group());
                } else{
                throw new Exception("msg");
                }
                if(m.find()){
                    endDate = format.parse(m.group());
                }else{
                throw new Exception("msg");
                }
                if (startDate!=null && endDate != null) {
                    if (ourDate.after(startDate) && ourDate.before(endDate)){
                        return true;
                    }
                    return false;
                }
    
    
                return false;   
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have thousands of HTML files to process using Groovy/Java and I need to
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.