Friday, December 30, 2016

Saturday, December 10, 2016

Date Time in Java 8

package com.ldap;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeTest {
private static final String DATE_FORMAT = "dd-M-yyyy hh:mm:ss a";
public static void main(String[] args) {

private static void datetime() {
String dateInString = "22-1-2015 10:15:55 AM";
        LocalDateTime ldt = LocalDateTime.parse(dateInString, DateTimeFormatter.ofPattern(DATE_FORMAT));

        ZoneId singaporeZoneId = ZoneId.of("Asia/Singapore");
        System.out.println("TimeZone : " + singaporeZoneId);

        //LocalDateTime + ZoneId = ZonedDateTime
        ZonedDateTime asiaZonedDateTime = ldt.atZone(singaporeZoneId);
        System.out.println("Date (Singapore) : " + asiaZonedDateTime);

        ZoneId newYokZoneId = ZoneId.of("America/New_York");
        System.out.println("TimeZone : " + newYokZoneId);
    LocalDateTime localdate =;
    LocalDateTime localdate2 =;
    DateTimeFormatter fmt = DateTimeFormatter.ISO_DATE_TIME;
System.out.println("---> "+localdate.format(fmt));
System.out.println("---> "+localdate2.format(fmt));
        ZonedDateTime nyDateTime = asiaZonedDateTime.withZoneSameInstant(newYokZoneId);
        System.out.println("Date (New York) : " + nyDateTime);

        DateTimeFormatter format = DateTimeFormatter.ofPattern(DATE_FORMAT);
        System.out.println("Date (Singapore) : " + format.format(asiaZonedDateTime));
        System.out.println("Date (New York) : " + format.format(nyDateTime));


Tuesday, December 6, 2016


7th Dec 2016

Thursday, November 24, 2016


To create a keyspace with Simple strategy 


  WITH REPLICATION = {'class' : 'SimpleStrategy''replication_factor' : 1 };

Memory efficient collections framework

Friday, November 4, 2016


Sunday, October 2, 2016

Autowiring into filter in Spring application

If you are facing problems autowiring dependencies in your filter class in Spring application Use the following trick.

public void doFilter(ServletRequest request, ServletResponse response, FilterChain filter)
throws IOException, ServletException {

$ ( Currency Sign ) Missing in Excel POI

If you are writing to a cell and find that currency sign is missing this could be because of the following reason.

Setting cell style is not enough

CellStyle dollarStyle=workbook.createCellStyle();
DataFormat df = workbook.createDataFormat();


You also need to set the cell style to NUMERIC


Sunday, August 21, 2016

App Ideas

list news paper stands nearby
Any electrical / cooker repair shops nearby  repair shops
Any small vendor like samosa , gol gappa , momo stand nearby
any place nearby to get some attestation done
price of newspaper in bangalore
price of liquor in bangalore ( brand wise)

Amazon groups : we can add amazon users to groups such as family , friends and share wallet etc.
Reporting of expenditure if amazon api is available.


cross marketplace integration.

all the above information though required is not available on google.

Monday, July 18, 2016

Wednesday, May 4, 2016

Simply WOW : Java Multi-threading wait return sequence

Many programmers
believe (incorrectly) that wait() returns as soon as the notify is issued, but that's simply not the case.
The wait() call doesn't return until the method that calls notify() releases the monitor.
Remember, you must be in the monitor to call either method. In the following code, wait() won't

return until the read() operation completes:

package lrxjava;

public class Dysfunctional {

public synchronized void reader()

System.out.println("Current time in nano  :" + System.currentTimeMillis());
try {
} catch (InterruptedException e) {


public synchronized void wait_for_read()

System.out.println("Current time in nano in wait :" + System.currentTimeMillis());
try {
System.out.println("Current time in nano in wait :" + System.currentTimeMillis());
} catch (InterruptedException e) {

public static void main(String[] args) {
Dysfunctional dysfunctional = new Dysfunctional();

Runnable task2 =   ()->dysfunctional.wait_for_read();
new Thread(task2).start();

Runnable task =   ()->dysfunctional.reader();
new Thread(task).start();