Here you can find the source of getDateFromIRODSValue(final String irodsValue)
java.util.Date
Parameter | Description |
---|---|
irodsValue | <code>String</code> containing an IRODS date value as returned from a query to ICAT |
java.util.Date
reflecting the IRODS time, or null
if no date in the data
public static Date getDateFromIRODSValue(final String irodsValue)
//package com.java2s; //License from project: BSD License import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { /**/*from w w w. ja v a 2 s . c o m*/ * Utility to return an irods date value as a <code>java.util.Date</code> * * @param irodsValue * <code>String</code> containing an IRODS date value as returned * from a query to ICAT * @return <code>java.util.Date</code> reflecting the IRODS time, or * <code>null</code> if no date in the data */ public static Date getDateFromIRODSValue(final String irodsValue) { if (irodsValue == null) { throw new IllegalArgumentException("null date value"); } if (irodsValue.isEmpty()) { return null; } Integer dateInteger; try { dateInteger = Integer.parseInt(irodsValue); } catch (NumberFormatException nfe) { throw new IllegalArgumentException( "malformed date value, cannot translate to integer:" + irodsValue); } TimeZone timeZone = TimeZone.getTimeZone("GMT"); DateFormat dateFormat = DateFormat.getDateTimeInstance(); dateFormat.setTimeZone(timeZone); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(0L); calendar.add(Calendar.SECOND, dateInteger.intValue()); Date computedDate = calendar.getTime(); return computedDate; } }