Here you can find the source of getShiftResult(ImmutableMap
public static LocalDateTime getShiftResult(ImmutableMap<String, Double> timexUnitMap, LocalDateTime reference, boolean future)
//package com.java2s; //License from project: Open Source License import java.time.LocalDateTime; import java.util.Map; import com.google.common.collect.ImmutableMap; public class Main { public static LocalDateTime getShiftResult(ImmutableMap<String, Double> timexUnitMap, LocalDateTime reference, boolean future) { LocalDateTime result = reference; int futureOrPast = future ? 1 : -1; for (Map.Entry<String, Double> pair : timexUnitMap.entrySet()) { String unit = pair.getKey(); Double number = pair.getValue(); switch (unit) { case "H": result = result.plusHours(Math.round(number * futureOrPast)); break; case "M": result = result.plusMinutes(Math.round(number * futureOrPast)); break; case "S": result = result.plusSeconds(Math.round(number * futureOrPast)); break; case "D": result = result.plusDays(Math.round(number * futureOrPast)); break; case "W": result = result.plusWeeks(Math.round(number * futureOrPast)); break; case "MON": result = result.plusMonths(Math.round(number * futureOrPast)); break; case "Y": result = result.plusYears(Math.round(number * futureOrPast)); break; default: return result; }//from w ww.jav a 2 s. c o m } return result; } }