Changeset 469 for tapas/common


Ignore:
Timestamp:
04/06/12 16:09:10 (12 years ago)
Author:
vmipsl
Message:

DateHelper? addHours

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tapas/common/implementation/com/ether/DateHelper.java

    r376 r469  
    11package com.ether; 
     2 
     3import org.apache.commons.logging.Log; 
     4import org.apache.commons.logging.LogFactory; 
     5import org.jetbrains.annotations.NotNull; 
     6import org.jetbrains.annotations.Nullable; 
    27 
    38import java.text.DateFormat; 
     
    712import java.util.Date; 
    813import java.util.Locale; 
    9  
    10 import org.apache.commons.logging.Log; 
    11 import org.apache.commons.logging.LogFactory; 
    12 import org.jetbrains.annotations.Nullable; 
    1314 
    1415/** 
     
    132133 
    133134    @Nullable 
    134     public static Date parseDate( @Nullable final String date, final String format ) throws ParseException 
     135    public static Date parseDate( @Nullable final String date, final String format ) 
     136            throws ParseException 
    135137    { 
    136         if( date == null ) 
     138        if( date == null ) 
    137139            return null; 
    138140 
    139141        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat( format ); 
    140         return simpleDateFormat.parse(date); 
     142        return simpleDateFormat.parse( date ); 
     143    } 
     144 
     145    /** 
     146     * This method add some hours to a date 
     147     * 
     148     * @param date 
     149     * @param hoursNumber 
     150     * @return 
     151     */ 
     152    public static Date addHourToDate( @NotNull final Date date, @NotNull final Integer hoursNumber ) 
     153    { 
     154        final Calendar calendar = Calendar.getInstance(); 
     155        calendar.setTime( date ); 
     156        calendar.add( Calendar.HOUR, hoursNumber ); 
     157        return calendar.getTime(); 
    141158    } 
    142159 
    143160    private static final Log LOGGER = LogFactory.getLog( DateHelper.class ); 
    144      
     161 
    145162    public static final String FRENCH_DATE_PATTERN_SHORT = "dd/MM/yyyy"; 
    146163    public static final String ENGLISH_DATE_PATTERN_SHORT = "yyyy-MM-dd"; 
Note: See TracChangeset for help on using the changeset viewer.