I want to display the arraylist like this:
[2013-11-01,2013-11-8,2013-11-15,2013-11-22,2013-11-29]
I am written the below code and i am passing the static values to that method:
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class DateExample {
Calendar cal = Calendar.getInstance();
public static void main(String[] args) {
DateExample date=new DateExample();
date.getAllDaysInaMonth("2013",11,1);
}
public List<java.sql.Date> getAllDaysInaMonth(String year,int month,int day){
System.out.println(year+""+month+""+day);
cal.set(Calendar.DAY_OF_MONTH, 1);
int utilyear=cal.get(cal.YEAR);
String syear= Integer.toString(utilyear);
int utilmonth=cal.get(cal.MONTH);
int utilday=cal.get(cal.DAY_OF_MONTH);
List<java.sql.Date> arraylist=new ArrayList<java.sql.Date>();
while (month==cal.get(Calendar.MONTH)) {
System.out.println("while"+cal.getTime());
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
String dateofutil=format.format(cal.getTime());
System.out.println("dateofutil"+dateofutil);
try {
java.sql.Date sqldate=new java.sql.Date(format.parse(dateofutil).getTime());
arraylist.add(sqldate);
} catch (ParseException e) {
e.printStackTrace();
}
cal.add(Calendar.DAY_OF_MONTH,1);
}
System.out.println("arraylist values"+arraylist);
return arraylist;
}
}
Here am passing static year,month,date to method as a parameters through that values am printing the dates like yyyy-MM-dd format when am passing 1 day then after 7 days date is printed
But the above code is not working properly give me correct code
There are two things to be changed here.
First,
while (month==cal.get(Calendar.MONTH)) {
needs to be changed to
while (month==cal.get(Calendar.MONTH)+1) {
because the according to docs
The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0;
and the second thing is to make your ArrayList of type String and not Date, because Date does not have a format. You can only get a formatted String representation of it.
List<String> arraylist = new ArrayList<String>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); // This can go out of the `while` loop though.
String dateofutil = format.format(cal.getTime());
arraylist.add(dateofutil);
You need to make the change below:
From
while (month==cal.get(Calendar.MONTH)) {
to
while ((month-1)==cal.get(Calendar.MONTH)) {
See more in Calendar.class ==> NOVEMBER , it is 10 rather 11. That's why previously you did not get the expected result. Change it and go ahead.
public final static int NOVEMBER = 10;
/**
* Value of the {#link #MONTH} field indicating the
* twelfth month of the year.
*/
public final static int DECEMBER = 11;
/**
* Value of the {#link #MONTH} field indicating the
* thirteenth month of the year. Although <code>GregorianCalendar</code>
* does not use this value, lunar calendars do.
*/
public final static int UNDECIMBER = 12;
The answer by R.J and the answer by MouseLearnJava are both correct.
This kind of date-time work is much easier using the Joda-Time library.
For one thing, Joda-Time counts from one unlike the zero-based silliness of java.util.Calendar. So the days of week are 1-7, months of year 1-12.
Here is some example code using Joda-Time 2.3 and Java 7.
// © 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.
// import org.joda.time.*;
// import org.joda.time.format.*;
// Data passed into method.
int year = 2014;
int month = 2;
int day = 2;
java.util.List<DateTime> dateTimes = new ArrayList<DateTime>();
DateTime start = new DateTime( year, month, day, 0, 0, 0 );
DateTime dateTime = start;
while( dateTime.monthOfYear().equals( start.monthOfYear() ) ) {
dateTimes.add( dateTime ); // Collect each date-time object.
dateTime = dateTime.plusDays( 7 );
}
System.out.println( "The list: " + dateTimes );
for( DateTime item : dateTimes ){
System.out.println( ISODateTimeFormat.date().print( item ) );
}
When run…
The list: [2014-02-02T00:00:00.000-08:00, 2014-02-09T00:00:00.000-08:00, 2014-02-16T00:00:00.000-08:00, 2014-02-23T00:00:00.000-08:00]
2014-02-02
2014-02-09
2014-02-16
2014-02-23
Related
This question already has answers here:
How to convert a String of format yyyymmdd to LocalDate in JodaTime [duplicate]
(1 answer)
Change date format in a Java string
(22 answers)
Good way to convert integer YYYYMMDD into java.util.Date with local time zone
(4 answers)
Closed 3 years ago.
I am trying to process the data from a weather station. I simply want to process and print (for now) the minimum and maximum temperatures each day starting from 2000/01/01 until today 2019/12/12. The weather station gives me the date in an integer yyyymmdd like 20191212 or 20030317. I store this, alongside the minimum and maximum temperatures in an integer array, of about 21000 rows long... I want the date to be displayed in yyyy/mm/dd, like 2019/12/12 or 2003/03/17. How exactly do I go about doing this?
This is my code
import java.io.*;
public class Main {
public static void main(String args[]) {
int rowAmount = 7152; //the amount of rows in the document
int[] temperatures = new int[rowAmount*3]; //makes an array 3 times the size of rowAmount, to fit date, min temp and max temp.
try {
BufferedReader br = new BufferedReader(new FileReader("D:\\20002019minmaxtempbilt.txt")); // Makes the filereader
String fileRead = br.readLine(); // reads first like
int counter = 0; //sets a counter
while (fileRead != null) { // loops until the file ends.
String[] tokenize = fileRead.split(","); //splits the line in 3 segements, date, min temp and max temp. And stores them in following variables
int tempDate = Integer.parseInt(tokenize[0]);
int tempMin = Integer.parseInt(tokenize[1]);
int tempMax = Integer.parseInt(tokenize[2]);
//adds the values to the array
temperatures[counter] = tempDate;
counter++;
temperatures[counter] = tempMin;
counter++;
temperatures[counter] = tempMax;
}
// close file stream
br.close();
}
catch (FileNotFoundException fnfe)
{
System.out.println("file not found");
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
// Displays the entire array, formatted by date neatly, hopefully.
for(int i = 0; i<rowAmount; i =+ 3) {
int tempDate = temperatures[i];
int tempMin = temperatures[i+1];
int tempMax = temperatures[i+2];
drawLine(tempDate, tempMin, tempMax);
}
}
public static void drawLine(int tempDate, int tempMin, int tempMax) {
/*This is where I get stuck. I need to convert tempDate from an int yyyymmdd to either
3 separate integers representing year, month and day; or I need to convert it to a
string that can be printed out yyyy/mm/dd.*/
System.out.printf("");
}
}
Since your date is a String to start with I see no reason to convert it to an Integer first. Using the more current java.time package you can use one formatter to convert from a String to LocalDate and then another to convert back to a String with the right format,
DateTimeFormatter inFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDate date = LocalDate.parse(tokenize[0], inFormatter);
DateTimeFormatter outFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
String outStr = outFormatter.format(date);
Since DateTimeFormatter is costly to initialise I would recommend you create both of them before the loop you have for reading the file.
Another way: if the integer value representing the date is stored in an int called date (example value: 20191212), then
int day = date % 100;
int month = (date/ 100) % 100;
int year = date / 10000;
then you can use a Formatter to format the string output that you want.
A problem is that an integer of 20191212 really doesn't represent a date.
I would recommend NOT transforming tempDate into an integer and leaving it as a string.
Edit
Here is an example that uses the Java 8 time package classes: LocalDate, DateTimeFormatter, and DateTimeFormatterBuilder:
package stackoverflow;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
public class ParseStringDate {
public static void main(String... args) {
String dateString = "20191231";
DateTimeFormatter dateTimeFormatterParser = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDate localDate = LocalDate.parse(dateString, dateTimeFormatterParser);
System.out.println(localDate);
DateTimeFormatter dateTimeFormatterPrinter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
System.out.println(localDate.format(dateTimeFormatterPrinter));
dateTimeFormatterPrinter = new DateTimeFormatterBuilder()
.appendPattern("yyyy")
.appendLiteral("/")
.appendPattern("MM")
.appendLiteral("/")
.appendPattern("dd").toFormatter();
System.out.println(localDate.format(dateTimeFormatterPrinter));
}
}
Here is an example that uses SimpleDateFormat:
package stackoverflow;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormattingFromString {
public static void main(String... args) throws Exception {
String tempDate = "20191212";
SimpleDateFormat sdf1 = new SimpleDateFormat("YYYYmmdd");
Date date = sdf1.parse(tempDate);
// Now format the above date as needed...
SimpleDateFormat sdf2 = new SimpleDateFormat("YYYY/mm/dd");
System.out.println(sdf2.format(date));
}
}
As pointed out in the comments, SimpleDateFormat and the Date classes are not super great to work with. They are mutable and therefore not thread safe. The new java.time package classes are immutable and therefore thread safe. The new classes are also easier to do date math with and comparisons.
I'd recommend using a DateFormat object, taking advantage of the parse(String) and format(Date) methods.
Apparently in a simple problem but I am being complicated with the treatment of dates. I need a date comparator that receives as parameters a date in yyyy-MM-dd format and a number (age) and that determines if it is above that number or below.
For example for 18, 1999-01-01 is above and would return true, but for 2010-01-01 false. If it were the year 2001, it would compare with the current month and year, that is, 2001-06-18 that was greater or less
I have this code using the gregorian api for the current date but I am unable.
I have this done
public static void main (String args[]) throws ParseException{
//SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//Date fechaInicial=(Date) dateFormat.parse("1999-01-01");
java.sql.Datedate1 = new Date(1999-01-01);
Calendar date2 = Calendar.getInstance();
boolean res = date(date1, date2);
}
public static boolean date(java.sql.Datedate1, Calendar date2 ){
//int year=18;
int y= date2.get(Calendar.YEAR)-18;
int m = date2.get(Calendar.MONTH)+1;
int d = date2.get(Calendar.DAY_OF_MONTH);
System.out.println(
String fechacompleta= y+"-"+m+"-"+d;
System.out.println(fechacompleta);
return ;
}
You can write your date method using java.time.LocalDate like this:
public static boolean date(LocalDate ld, int age) {
Period p = Period.between(ld, LocalDate.now());
return p.getYears() >= age;
}
It computes the Period between a certain date and now, and returns whether that period is greater than or equal to 18 years.
You can create a LocalDate like this:
LocalDate ld = LocalDate.parse("2001-12-23", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
And pass it into date:
if (date(ld, 18)) {
// 18 or above!
}
I have tried this code. I got the output but not the right one...
//Iam getting my answer after the following changes below...
package patternsamp;
import java.io.*;
import java.util.*;
public class Mydate
{
static void test()
{
Date da = new Date(5,9,2014,07,00,00);
System.out.println(da.toGMTString());
}
public static void main(String[] args)
{
Mydate.test();
}
}
//I made the changes like this.....
Date da = new Date(114,8,5,12,30,0);
OUTPUT: 5 Sep 2014 07:00:00 GMT
This gives me right output... Thanks for your support friends.....
To get the sep 5 as output, shuold be given as 5-9,
Try using simpledateformat:
SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
String dateInString = "5-9-2014 07:00:00";
Date date = sdf.parse(dateInString);
System.out.println(date);
Quoting from Java Doc
Date(int year, int month, int date, int hrs, int min, int sec)
`Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date, hrs, min, sec) or GregorianCalendar(year + 1900, month, date, hrs, min, sec).`
Avoid using Date constructor (to set dates) at all, incase you insist maintain correct order of parameters, your code should look like this:-
package patternsamp;
import java.io.*;
import java.util.*;
public class Mydate
{
static void test()
{
Date da = new Date(114,9,5,07,00,00);
System.out.println(da.toGMTString());
}
public static void main(String[] args)
{
Mydate.test();
}
Note that I am using 114 in the year (and not 2014), since according to doc
A year y is represented by the integer y - 1900.
Hence to represent 2014 , you have to 2014-1900, which is 114.
if your project imported commons-lang.jar
you can get the Date object from String like this:
DateUtils.parseDate("2014-08-20",new String[]{"yyyy-MM-dd"})
Joda-Time
So much easier and sensible to use the Joda-Time library rather than the notoriously troublesome bundled java.util.Date and .Calendar classes. To specify a year, you specify a year (2014 rather than 114). To specify a month, you specify a month (9 means September rather than 8).
DateTime dateTime = new DateTime( 2014, 9, 5, 7, 0, 0, DateTimeZone.UTC );
If you must have a java.util.Date object, convert.
java.util.Date date = dateTime.toDate();
I know how to convert local time to UTC time and vice versa.
But I am very much confused about daylight savings time(DST) handling while doing this.
So can anyone answer the below questions:
1. Does java internally handle DST when converting between timezones?
2. What things I need to do while converting between timezones?
3. Any good article which explains about this more clearly?
Thanks in advance.
Are you sure you know how to convert dates to UTC and back? Correctly?
I am afraid, I doubt that.
Yes.
You don't need to convert, you just need to assign correct TimeZone.
What you need an article for? OK, I am working on this, but for now let me put an answer here.
The first thing first. Your program should store Date (or Calendar) in UTC TimeZone internally. Well, in fact in GMT, because there are no leap seconds in Java, but that is another story.
The only place when you should be in need of "converting", is when you are going to display the time to user. That regards to sending email messages as well. In both cases you need to format date to get its textual representation. To that you would use DateFormat and assign correct TimeZone:
// that's for desktop application
// for web application one needs to detect Locale
Locale locale = Locale.getDefault();
// again, this one works for desktop application
// for web application it is more complicated
TimeZone currentTimeZone = TimeZone.getDefault();
// in fact I could skip this line and get just DateTime instance,
// but I wanted to show how to do that correctly for
// any time zone and locale
DateFormat formatter = DateFormat.getDateTimeInstance(
DateFormat.DEFAULT,
DateFormat.DEFAULT,
locale);
formatter.setTimeZone(currentTimeZone);
// Dates "conversion"
Date currentDate = new Date();
long sixMonths = 180L * 24 * 3600 * 1000;
Date inSixMonths = new Date(currentDate.getTime() + sixMonths);
System.out.println(formatter.format(currentDate));
System.out.println(formatter.format(inSixMonths));
// for me it prints
// 2011-05-14 16:11:29
// 2011-11-10 15:11:29
// now for "UTC"
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(formatter.format(currentDate));
System.out.println(formatter.format(inSixMonths));
// 2011-05-14 14:13:50
// 2011-11-10 14:13:50
As you can see, Java cares about handling DST. You can of course handle it manually, just read the TimeZone related JavaDoc.
Here is the best solution that I've found. I'm copying it here, but the solution came from http://biese.wordpress.com/2014/02/28/the-easy-way-to-convert-local-time-to-utc-time/.
package com.test.timezone;
import java.util.TimeZone;
public final class Utility {
public static final TimeZone utcTZ = TimeZone.getTimeZone("UTC");
public static long toLocalTime(long time, TimeZone to) {
return convertTime(time, utcTZ, to);
}
public static long toUTC(long time, TimeZone from) {
return convertTime(time, from, utcTZ);
}
public static long convertTime(long time, TimeZone from, TimeZone to) {
return time + getTimeZoneOffset(time, from, to);
}
private static long getTimeZoneOffset(long time, TimeZone from, TimeZone to) {
int fromOffset = from.getOffset(time);
int toOffset = to.getOffset(time);
int diff = 0;
if (fromOffset >= 0){
if (toOffset > 0){
toOffset = -1*toOffset;
} else {
toOffset = Math.abs(toOffset);
}
diff = (fromOffset+toOffset)*-1;
} else {
if (toOffset <= 0){
toOffset = -1*Math.abs(toOffset);
}
diff = (Math.abs(fromOffset)+toOffset);
}
return diff;
}
}
package com.test.timezone;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
public class TestTimezone {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMM dd HH:mm:ss zzzz");
Calendar date1 = new GregorianCalendar(2014,0,15,10,0,0);
System.out.println(sdf.format(date1.getTime())+"\n");
long utcTimeStamp = Utility.toUTC(date1.getTimeInMillis(), date1.getTimeZone());
Calendar utcCal = Calendar.getInstance();
utcCal.setTimeInMillis(utcTimeStamp);
System.out.println("toUTC: "+sdf.format(utcCal.getTime())+"\n");
System.out.println("---------------------------------------");
Calendar date2 = new GregorianCalendar(2014,2,15,10,0,0);
System.out.println(sdf.format(date2.getTime())+"\n");
utcTimeStamp = Utility.toUTC(date2.getTimeInMillis(), date2.getTimeZone());
utcCal.setTimeInMillis(utcTimeStamp);
System.out.println("toUTC: "+sdf.format(utcCal.getTime())+"\n");
System.out.println("---------------------------------------");
Calendar date3 = new GregorianCalendar(2014,11,25,9,0,0);
System.out.println(sdf.format(date3.getTime())+"\n");
long uTime = Utility.toUTC(date3.getTimeInMillis(), date3.getTimeZone());
System.out.println("utcTimeStamp: "+uTime+"\n");
long lTime = Utility.toLocalTime(uTime, TimeZone.getTimeZone("EST"));
Calendar locCal = Calendar.getInstance();
locCal.setTimeInMillis(lTime);
System.out.println("toLocal: "+sdf.format(locCal.getTime())+"\n");
System.out.println("---------------------------------------");
Calendar date4 = new GregorianCalendar(2014,6,4,9,0,0);
System.out.println(sdf.format(date4.getTime())+"\n");
uTime = Utility.toUTC(date4.getTimeInMillis(), date4.getTimeZone());
System.out.println("utcTimeStamp: "+uTime+"\n");
lTime = Utility.toLocalTime(uTime, TimeZone.getTimeZone("EST"));
locCal = Calendar.getInstance();
locCal.setTimeInMillis(lTime);
System.out.println("toLocal: "+sdf.format(locCal.getTime())+"\n");
}
}
The code in TALE's answer can be simplified:
public final class Utility {
public static long toLocalTime(long time, TimeZone to) {
return time + to.getOffset(time);
}
public static long toUTC(long time, TimeZone from) {
return time - from.getOffset(time);
}
}
Can I get localized short day-in-week name (Mo/Tu/We/Th/Fr/Sa/Su for English) in Java?
The best way is with java.text.DateFormatSymbols
DateFormatSymbols symbols = new DateFormatSymbols(new Locale("it"));
// for the current Locale :
// DateFormatSymbols symbols = new DateFormatSymbols();
String[] dayNames = symbols.getShortWeekdays();
for (String s : dayNames) {
System.out.print(s + " ");
}
// output : dom lun mar mer gio ven sab
If standard abbreviations are fine with you, just use Calendar class like this:
myCal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US);
An example using SimpleDateFormat:
Date now = new Date();
// EEE gives short day names, EEEE would be full length.
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE", Locale.US);
String asWeek = dateFormat.format(now);
SimpleDateFormat as been around longer than the C-style String.format and System.out.printf, and I think you'd find most Java developers would be more familiar with it and more in use in existing codebases, so I'd recommend that approach.
java.time
Update for those using Java 8 and later.
ZoneId zoneId = ZoneId.of("America/Los_Angeles");
Instant instant = Instant.now();
ZonedDateTime zDateTime = instant.atZone(zoneId);
DayOfWeek day = zDateTime.getDayOfWeek();
Show output.
System.out.println(day.getDisplayName(TextStyle.SHORT, Locale.US));
System.out.println(day.getDisplayName(TextStyle.NARROW, Locale.US));
When run. See similar code run live at IdeOne.com.
Tue
T
DateTimeFormatter#localizedBy
Starting with Java SE 10, you can use DateTimeFormatter#localizedBy.
Demo:
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
public class Main {
public static void main(String args[]) {
DateTimeFormatter dtfHindi = DateTimeFormatter.ofPattern("E").localizedBy(Locale.forLanguageTag("hi"));
DateTimeFormatter dtfBangla = DateTimeFormatter.ofPattern("E").localizedBy(Locale.forLanguageTag("bn"));
DateTimeFormatter dtfGerman = DateTimeFormatter.ofPattern("E").localizedBy(Locale.forLanguageTag("de"));
DateTimeFormatter dtfEnglish = DateTimeFormatter.ofPattern("E").localizedBy(Locale.forLanguageTag("en"));
// Replace ZoneId.systemDefault() with the applicable timezone e.g.
// ZoneId.of("Asia/Calcutta")
LocalDate today = LocalDate.now(ZoneId.systemDefault());
System.out.println(dtfHindi.format(today));
System.out.println(dtfBangla.format(today));
System.out.println(dtfGerman.format(today));
System.out.println(dtfEnglish.format(today));
}
}
Output:
शुक्र
শুক্র
Fr.
Fri
Alternatively, starting with Java SE 8, you can use DayOfWeek#getDisplayName with the applicable Locale.
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.TextStyle;
import java.util.Locale;
public class Main {
public static void main(String args[]) {
// Replace ZoneId.systemDefault() with the applicable timezone e.g.
// ZoneId.of("Asia/Calcutta")
LocalDate today = LocalDate.now(ZoneId.systemDefault());
System.out.println(today.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.forLanguageTag("hi")));
System.out.println(today.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.forLanguageTag("bn")));
System.out.println(today.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.forLanguageTag("de")));
System.out.println(today.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.forLanguageTag("en")));
}
}
Output:
शुक्र
শুক্র
Fr.
Fri
You can't do it with the Calendar class (unless you write your own), but you can with the Date class. (The two are usually used hand-in-hand).
Here's an example:
import java.util.Date;
public class DateFormatExample {
public static void main(String[] args) {
Calendar nowCal = Calendar.getInstance(); // a Calendar date
Date now = new Date(nowCal.getTimeInMillis()); // convert to Date
System.out.printf("localized month name: %tB/%TB\n", now, now);
System.out.printf("localized, abbreviated month: %tb/%Tb\n", now, now);
System.out.printf("localized day name: %tA/%TA\n", now, now);
System.out.printf("localized, abbreviated day: %ta/%Ta\n", now, now);
}
}
Output:
localized month name: June/JUNE
localized, abbreviated month: Jun/JUN
localized day name: Friday/FRIDAY
localized, abbreviated day: Fri/FRI
You can use this :
public String getDayString(){
Locale locale = Locale.getDefault();
LocalDate date = LocalDate.now();
DayOfWeek day = date.getDayOfWeek();
return day.getDisplayName(TextStyle.FULL, locale);
}
The result will be: Monday
//you need to use joda library
List<String> dayList = new ArrayList<String>();
String[] days = new String[7];
int a=2;
//a =starting day of week 1=sunday ,2=monday
Calendar c2 = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
c2.set((Calendar.DAY_OF_WEEK),a);
int maxDay = c2.getActualMaximum(Calendar.DAY_OF_WEEK);
for(int i=0;i<maxDay;i++)
{
days[i] = df.format(c2.getTime());
c2.add(Calendar.DAY_OF_MONTH, 1);
String dayOfWeek = new LocalDate( days[i]).dayOfWeek().getAsShortText();
dayList.add(dayOfWeek);
}
for(int i=0;i<maxDay;i++)
{
System.out.print(" '"+dayList.get(i)+"'");
}