How to bind ip address in redis server

step 1 : vim /etc/hosts

step 2 : vim /etc/redis/redis.conf

change bind ip address propertiy in above files

Advertisements

how to give number format in apache poi api while export excel

if(data.getStocks() == null){
getCell(dataRow1, 10).setCellType(Cell.CELL_TYPE_BLANK);
getCell(dataRow1, 10).setCellValue(” “);
}
else{
getCell(dataRow1, 10).setCellType(Cell.CELL_TYPE_NUMERIC);
long num = Long.parseLong(data.
getStocks().toString());
getCell(dataRow1, 10).setCellValue(num);
}

how to give number format for quantity and value in apache poi api while export excel

if(data.getQuantity() == null){
getCell(dataRow1, 10).setCellType(Cell.CELL_TYPE_BLANK);
getCell(dataRow1, 10).setCellValue(“”);
}
else{
CellStyle cellStyle = ExcelExportCommonUtil
.rightAlinmebtCellStyle(workbook);

cellStyle.setDataFormat(workbook
.createDataFormat().getFormat(
“0.000”));
getCell(dataRow1, 10).setCellType(Cell.CELL_TYPE_NUMERIC);
double quantity = Double
.parseDouble(data.getQuantity()
.toString()
.replace(“,”, “”));

getCell(dataRow1, 10).setCellValue(quantity);
getCell(dataRow1, 10).setCellStyle(cellStyle);
}

MySQL DATE_FORMAT() Function

Definition and Usage

The DATE_FORMAT() function is used to display date/time data in different formats.

Syntax

DATE_FORMAT(date,format)

Where date is a valid date and format specifies the output format for the date/time.

The formats that can be used are:

Format Description
%a Abbreviated weekday name (Sun-Sat)
%b Abbreviated month name (Jan-Dec)
%c Month, numeric (0-12)
%D Day of month with English suffix (0th, 1st, 2nd, 3rd, �)
%d Day of month, numeric (00-31)
%e Day of month, numeric (0-31)
%f Microseconds (000000-999999)
%H Hour (00-23)
%h Hour (01-12)
%I Hour (01-12)
%i Minutes, numeric (00-59)
%j Day of year (001-366)
%k Hour (0-23)
%l Hour (1-12)
%M Month name (January-December)
%m Month, numeric (00-12)
%p AM or PM
%r Time, 12-hour (hh:mm:ss followed by AM or PM)
%S Seconds (00-59)
%s Seconds (00-59)
%T Time, 24-hour (hh:mm:ss)
%U Week (00-53) where Sunday is the first day of week
%u Week (00-53) where Monday is the first day of week
%V Week (01-53) where Sunday is the first day of week, used with %X
%v Week (01-53) where Monday is the first day of week, used with %x
%W Weekday name (Sunday-Saturday)
%w Day of the week (0=Sunday, 6=Saturday)
%X Year for the week where Sunday is the first day of week, four digits, used with %V
%x Year for the week where Monday is the first day of week, four digits, used with %v
%Y Year, numeric, four digits
%y Year, numeric, two digits

Example

The following script uses the DATE_FORMAT() function to display different formats. We will use the NOW() function to get the current date/time:

DATE_FORMAT(NOW(),’%b %d %Y %h:%i %p’)
DATE_FORMAT(NOW(),’%m-%d-%Y’)
DATE_FORMAT(NOW(),’%d %b %y’)
DATE_FORMAT(NOW(),’%d %b %Y %T:%f’)

The result would look something like this:

Nov 04 2014 11:45 PM
11-04-2014
04 Nov 14
04 Nov 2014 11:45:34:243

How to get start datetime and end datetime for a day ,month and year

public Date getEndOfDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}

public Date getStartOfDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}

public Date getStartOfMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
public Date getEndOfMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}
public Date getStartOfYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
public Date getEndOfYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR, calendar.getActualMaximum(Calendar.DAY_OF_YEAR));
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}

 

——————————-

String dayStartTime=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(getStartOfDay(new Date()));
String dayEndTime=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(getEndOfDay(new Date()));
log.info(“start time of the day :-“+dayStartTime);
log.info(“end time of the day :-“+dayEndTime);

String monthStartTime=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(getStartOfMonth(new Date()));
String monthEndTime = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(getEndOfMonth(new Date()));
log.info(“start time of the month :- “+monthStartTime);
log.info(“end time of the month :- “+monthEndTime);

String yearStartTime=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(getStartOfYear(new Date()));
String yearEndTime=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(getEndOfYear(new Date()));
log.info(“start time of the year :-“+yearStartTime);
log.info(“end time of the year :-“+yearEndTime);