Here you can find the source of parseDate(Map obj, String field, String format)
private static Date parseDate(Map obj, String field, String format)
//package com.java2s; /*/*from w w w . ja va 2 s . c o m*/ * Sonar, open source software quality management tool. * Copyright (C) 2008-2011 SonarSource * mailto:contact AT sonarsource DOT com * * Sonar is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * Sonar is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; public class Main { private static Date parseDate(Map obj, String field, String format) { String value = getString(obj, field); if (value != null) { try { SimpleDateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.parse(value); } catch (ParseException e) { throw new RuntimeException(e); } } return null; } public static String getString(Map obj, String field) { Object value = obj.get(field); if (value != null) { return (String) value; } return null; } }