Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38324

Re: I need to get files with different timespan 1hr, 1day.1 week

Newsgroups comp.lang.java.programmer
Date 2018-05-31 22:02 -0700
References <a8a31edc-333e-48fd-a7e0-34f38c9e0d5d@googlegroups.com> <peond1$3ai$1@dont-email.me> <6ba6236b-78bd-4224-a7be-a0dcb28e1a9a@googlegroups.com> <peovkh$r6f$1@dont-email.me>
Message-ID <99181ebf-320d-4c54-98b8-4dec13652ea2@googlegroups.com> (permalink)
Subject Re: I need to get files with different timespan 1hr, 1day.1 week
From msr2858@gmail.com

Show all headers | View raw


On Thursday, May 31, 2018 at 7:38:28 PM UTC+5:30, Eric Sosman wrote:
> On 5/31/2018 8:59 AM, siddareddy.moolam@gmail.com wrote:
> > On Thursday, May 31, 2018 at 5:17:56 PM UTC+5:30, Eric Sosman wrote:
> >> On 5/31/2018 6:07 AM, siddareddy.moolam@gmail.com wrote:
> >>> i have a folder with different files with different dates i need to get if one hour file is there or not,need to display file name
> >>> after that 1 day file need to displayed
> >>>
> >>> after 1 week file name should be displayed ..
> >>> Ex:
> >>>
> >>> 31-05-2018 folder inside filename is like these : 31-05-2018_10-42-25_rakesh_hike_load_608_output.txt if i need to enter 1 day details i need to display that file
> >>
> >>       What difficulty are you having?
> >> [...]
> > 
> > not working for me ........its displaying folders name only can you send me your mail id will send you full images
> > 
> 
>      One skill every programmer must cultivate is the ability to
> formulate a careful and complete description of a problem.  When
> you have mastered that skill -- or when you have even begun to
> demonstrate that you are trying to learn it -- somebody will
> surely try to help you.  Until then ...
> 
> 	"Doctor, it hurts!"
> 
> 	"What hurts?"
> 
> 	"Just hurry up and cure me!"
> 
> -- 
> esosman@comcast-dot-net.invalid
> Nine hundred sixty-five days to go.

Problem:
IAm able to get one day files but i didnt get one hour and one week files could please help me 
Thanks!
Sidda



FDate.java:


package hellomongo;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class FDate {
	String stringToday1;
	String path;
	String base="/home/msr/hike/";	    

	public void getdayfilnames() {
		Date today1 = new Date();
        System.out.println("today1 :: " + today1);    
	   // let us convert different formats of today1 into strings
    	SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
    	stringToday1 = sdf1.format(today1);
        System.out.println("today1 :: " + stringToday1);
		
		path=base+stringToday1; 
		System.out.println("dayysss:"+ path);
		File folder = new File(path);
		File[] listOfFiles = folder.listFiles();
		
		
		    for (int i = 0; i < listOfFiles.length; i++) {
		    	if (listOfFiles[i].isFile()) {
		    		 String fname=listOfFiles[i].getName();
		    		 
		    		 
		    		 
		    		System.out.print("  "+fname+"  ");
		    	}
		    	
		   
		      /*if (listOfFiles[i].isFile()) {
		    	  String fname=listOfFiles[i].getName();
		    	  System.out.println(" fname :"+fname);
		    	  String dayfile=fname.substring(1, 10);
		    	  if(day==dayfile) {
		    		  System.out.println(fname);
		    	  }
		      } */
		    }

		
	}
}
main Method:



package hellomongo;

import java.io.File;
import java.io.FilenameFilter;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Timedate {

	public static void main(String[] args) 
	{
		
	Timedate td=new Timedate();
	FDate fd=new FDate();
	fd.getdayfilnames();
	
	  }
	}
	
Excepted Output:

dayysss:/home/msr/hike/01-06-2018:

31-05-2018_10-42-25_rakesh_hike_load_608_output.txt
31-05-2018_10-42-38_rakesh_hike_cpu_bd7_output.txt
31-05-2018_10-42-46_rakesh_hike_ram_d8c_output.txt
	      
	    
	




Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I need to get files with different timespan 1hr, 1day.1 week siddareddy.moolam@gmail.com - 2018-05-31 03:07 -0700
  Re: I need to get files with different timespan 1hr, 1day.1 week Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-05-31 07:47 -0400
    Re: I need to get files with different timespan 1hr, 1day.1 week siddareddy.moolam@gmail.com - 2018-05-31 05:59 -0700
      Re: I need to get files with different timespan 1hr, 1day.1 week Eric Douglas <e.d.programmer@gmail.com> - 2018-05-31 06:52 -0700
      Re: I need to get files with different timespan 1hr, 1day.1 week Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-05-31 15:53 +0200
      Re: I need to get files with different timespan 1hr, 1day.1 week Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-05-31 10:08 -0400
        Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-05-31 22:02 -0700
        Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-05-31 22:08 -0700
          Re: I need to get files with different timespan 1hr, 1day.1 week Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-06-01 07:43 -0400
  Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-06-01 04:57 -0700
  Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-06-01 04:58 -0700
  Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-06-01 05:00 -0700
    Re: I need to get files with different timespan 1hr, 1day.1 week Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-06-01 16:08 +0200

csiph-web